配置文件支持


🌐 Configuration file support

除了在命令行上传递权限标志外,在使用实验性[--experimental-config-file][]标志时,它们也可以在 Node.js 配置文件中声明。权限选项必须放在 permission 顶层对象中。

🌐 In addition to passing permission flags on the command line, they can also be declared in a Node.js configuration file when using the experimental [--experimental-config-file][] flag. Permission options must be placed inside the permission top-level object.

示例 node.config.json

🌐 Example node.config.json:

{
  "permission": {
    "allow-fs-read": ["./foo"],
    "allow-fs-write": ["./bar"],
    "allow-child-process": true,
    "allow-worker": true,
    "allow-net": true,
    "allow-addons": false
  }
} 

当配置文件中存在 permission 命名空间时,Node.js 会自动启用 --permission 标志。运行命令如下:

🌐 When the permission namespace is present in the configuration file, Node.js automatically enables the --permission flag. Run with:

$ node --experimental-default-config-file app.js