From 93ea0abbc811060a9b68ffabb39fc6a04a1909a2 Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Thu, 9 Jan 2025 18:45:37 -0300 Subject: [PATCH] doc: add section about using npx with permission model --- doc/api/permissions.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/api/permissions.md b/doc/api/permissions.md index ea3ccc17b306b7..d750fa5b79f14a 100644 --- a/doc/api/permissions.md +++ b/doc/api/permissions.md @@ -126,6 +126,21 @@ does not exist, the wildcard will not be added, and access will be limited to yet, make sure to explicitly include the wildcard: `/my-path/folder-do-not-exist/*`. +#### Enabling Permission Model with npx + +If you're using `npx` to execute a Node.js script, you can enable the Permission +Model by using the `--node-options` flag. + +```bash +npx --node-options="--permission --allow-fs-read=./" your-script +``` + +This argument will set the `NODE_OPTIONS` environment variable to all +Node.js processes spawned by `npx` (without affecting `npx` itself!). + +Any arguments you would normally pass directly to `node` +(such as `--allow-*` flags) can also be passed through `--node-options`. + #### Permission Model constraints There are constraints you need to know before using this system: