require.resolve(request[, options])
-
request<string> 要解析的模块路径。¥
request<string> The module path to resolve. -
options<Object>-
paths<string[]> 从中解析模块位置的路径。如果存在,将使用这些路径而不是默认解析路径,但 GLOBAL_FOLDERS 和$HOME/.node_modules除外,它们始终包含在内。这些路径中的每一个都用作模块解析算法的起点,这意味着从此位置检查node_modules层级。¥
paths<string[]> Paths to resolve module location from. If present, these paths are used instead of the default resolution paths, with the exception of GLOBAL_FOLDERS like$HOME/.node_modules, which are always included. Each of these paths is used as a starting point for the module resolution algorithm, meaning that thenode_moduleshierarchy is checked from this location.
-
-
返回:<string>
¥Returns: <string>
使用内部的 require() 工具查找模块的位置,但不加载模块,只返回解析的文件名。
¥Use the internal require() machinery to look up the location of a module,
but rather than loading the module, just return the resolved filename.
如果找不到模块,则会抛出 MODULE_NOT_FOUND 错误。
¥If the module can not be found, a MODULE_NOT_FOUND error is thrown.