配置文件支持
🌐 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-addons": false
}
} 使用配置文件运行:
🌐 Run with the configuration file:
$ node --permission --experimental-default-config-file app.js