module.register(specifier[, parentURL][, options])


稳定性: 1.2 - 发布候选版

  • specifier <string> | <URL> 要注册的自定义钩子;这应该与传递给 import() 的字符串相同,除非它是相对路径,相对路径将相对于 parentURL 解析。
  • parentURL <string> | <URL> 如果你想要相对于一个基 URL(例如 import.meta.url)解析 specifier,你可以在这里传入该 URL。默认值: 'data:'
  • options <Object>
    • parentURL <string> | <URL> 如果你想基于某个基础 URL(例如 import.meta.url)解析 specifier,可以在此处传递该 URL。如果 parentURL 作为第二个参数提供,则会忽略此属性。默认值: 'data:'
    • data <any> 任何可任意克隆的 JavaScript 值,用于传入 initialize 钩子。
    • transferList <Object[]> 可转移对象 将传入 initialize 钩子。

注册一个模块,该模块导出 钩子,用于自定义 Node.js 模块的解析和加载行为。参见 自定义钩子

【Register a module that exports hooks that customize Node.js module resolution and loading behavior. See Customization hooks.】

如果与 权限模型 一起使用此功能,则需要 --allow-worker

【This feature requires --allow-worker if used with the Permission Model.】