module.setSourceMapsSupport(enabled[, options])


  • enabled <boolean> 启用源映射支持。
  • options <Object> 可选
    • nodeModules <boolean> 如果启用对 node_modules 中文件的支持。默认值: false
    • generatedCode <boolean> 如果启用对来自 evalnew Function 的生成代码的支持。默认值: false

此功能用于启用或禁用对堆栈跟踪的 源映射 v3 支持。

【This function enables or disables the Source Map v3 support for stack traces.】

它提供与使用命令行选项 --enable-source-maps 启动 Node.js 进程相同的功能,同时增加了用于修改对 node_modules 中的文件或生成的代码支持的附加选项。

【It provides same features as launching Node.js process with commandline options --enable-source-maps, with additional options to alter the support for files in node_modules or generated codes.】

只有在启用源映射后加载的 JavaScript 文件中的源映射才会被解析和加载。最好使用命令行选项 --enable-source-maps,以避免在调用此 API 之前加载的模块的源映射丢失。

【Only source maps in JavaScript files that are loaded after source maps has been enabled will be parsed and loaded. Preferably, use the commandline options --enable-source-maps to avoid losing track of source maps of modules loaded before this API call.】