--allow-ffi
稳定性: 1.1 - 处于活跃开发中
在使用 权限模型 时,默认情况下该过程将无法使用 FFI API。尝试使用 FFI API 将抛出 ERR_ACCESS_DENIED 异常,除非用户在启动 Node.js 时显式传递 --allow-ffi 标志。node:ffi 模块同样需要 --experimental-ffi 标志,并且仅在支持 FFI 的构建中可用。
🌐 When using the Permission Model, the process will not be able to use FFI
APIs by default. Attempts to use FFI APIs will throw an ERR_ACCESS_DENIED
exception unless the user explicitly passes the --allow-ffi flag when
starting Node.js. The node:ffi module also requires the
--experimental-ffi flag and is only available in builds with FFI support.
示例:
🌐 Example:
const { DynamicLibrary } = require('node:ffi');
const lib = new DynamicLibrary('mylib.so'); $ node --permission --experimental-ffi index.js
Error: Access to this API has been restricted. Use --allow-ffi to manage permissions.
at node:internal/main/run_main_module:17:47 {
code: 'ERR_ACCESS_DENIED',
permission: 'FFI'
}