require.resolve(request[, options])


  • request <string> 需要解析的模块路径。
  • options <Object>

    • paths <string[]> 解析模块的起点路径。此参数存在时,将使用这些路径而非默认解析路径。    注意此数组中的每一个路径都被用作模块解析算法的起点,意味着 node_modules 层级将从这里开始查询。
  • Returns: <string>

使用内部的 require() 机制查询模块的位置, 此操作只返回解析后的文件名,不会加载该模块。

  • request <string> The module path to resolve.
  • options <Object>

    • 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. Note that each of these paths is used as a starting point for the module resolution algorithm, meaning that the node_modules hierarchy is checked from this location.
  • Returns: <string>

Use the internal require() machinery to look up the location of a module, but rather than loading the module, just return the resolved filename.