--allow-inspector
稳定性: 1.0 - 早期开发
使用 权限模型 时,该过程将无法通过检查器协议进行连接。
【When using the Permission Model, the process will not be able to connect through inspector protocol.】
除非用户在启动 Node.js 时显式传递 --allow-inspector 标志,否则尝试这样做会抛出 ERR_ACCESS_DENIED。
【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',
}