--allow-inspector
稳定性: 1.0 - 早期开发
¥Stability: 1.0 - Early development
使用 权限模型 时,进程将无法通过检查器协议进行连接。
¥When using the Permission Model, the process will not be able to connect through inspector protocol.
尝试这样做将抛出 ERR_ACCESS_DENIED,除非用户在启动 Node.js 时明确传递 --allow-inspector 标志。
¥Attempts to do so will throw an ERR_ACCESS_DENIED unless the
user explicitly passes the --allow-inspector flag when starting Node.js.
示例:
¥Example:
const { Session } = require('node:inspector/promises');
const session = new Session();
session.connect(); $ node --permission index.js
Error: connect ERR_ACCESS_DENIED Access to this API has been restricted. Use --allow-inspector to manage permissions.
code: 'ERR_ACCESS_DENIED',
}