--allow-fs-read
¥Stability: 1.1 - Active development
此标志使用 权限模型 配置文件系统读取权限。
¥This flag configures file system read permissions using the Permission Model.
--allow-fs-read
标志的有效参数是:
¥The valid arguments for the --allow-fs-read
flag are:
-
*
- 允许所有FileSystemRead
操作。¥
*
- To allow allFileSystemRead
operations. -
使用多个
--allow-fs-read
标志可以允许多个路径。示例--allow-fs-read=/folder1/ --allow-fs-read=/folder1/
¥Multiple paths can be allowed using multiple
--allow-fs-read
flags. Example--allow-fs-read=/folder1/ --allow-fs-read=/folder1/
不再允许使用逗号 (,
) 分隔的路径。当传递带有逗号的单个标志时,将显示警告。
¥Paths delimited by comma (,
) are no longer allowed.
When passing a single flag with a comma a warning will be displayed.
可以在 文件系统权限 文档中找到示例。
¥Examples can be found in the File System Permissions documentation.
CLI 标志尚不支持相对路径。
¥Relative paths are NOT yet supported by the CLI flag.
初始化模块也需要被允许。考虑以下示例:
¥The initializer module also needs to be allowed. Consider the following example:
$ node --experimental-permission t.js
node:internal/modules/cjs/loader:162
const result = internalModuleStat(filename);
^
Error: Access to this API has been restricted
at stat (node:internal/modules/cjs/loader:162:18)
at Module._findPath (node:internal/modules/cjs/loader:640:16)
at resolveMainPath (node:internal/modules/run_main:15:25)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:53:24)
at node:internal/main/run_main_module:23:47 {
code: 'ERR_ACCESS_DENIED',
permission: 'FileSystemRead',
resource: '/Users/rafaelgss/repos/os/node/t.js'
}
该进程需要访问 index.js
模块:
¥The process needs to have access to the index.js
module:
node --experimental-permission --allow-fs-read=/path/to/index.js index.js