File Explorer

/proc/self/task/4/root/var/lang/lib/node_modules/npm/docs/content/commands

This explorer reads the filesystem of the server it runs on, so /workspace/user isn't present here. Browsing and the terminal still work against this server's own disk from /.

npm-install-scripts.md5.5 KB · 167 lines
---title: npm-install-scriptssection: 1description: Manage install-script approvals for dependencies--- ### Synopsis ```bashnpm install-scripts approve <pkg> [<pkg> ...]npm install-scripts approve --allnpm install-scripts deny <pkg> [<pkg> ...]npm install-scripts deny --allnpm install-scripts lsnpm install-scripts prune``` Note: This command is unaware of workspaces. ### Description Manages the `allowScripts` field in your project's `package.json`, whichrecords which of your dependencies are permitted to run install scripts(`preinstall`, `install`, `postinstall`, and `prepare` for non-registrysources). This is the recommended way to maintain that field. Dependency install scripts are blocked by default. Install commandssilently skip lifecycle scripts for any dependency that does not have amatching entry in `allowScripts`, and end with a list of the packageswhose scripts were skipped so you can review them here. This command only works inside a project that has a `package.json`. Runningit with `--global` (`-g`) fails with an `EGLOBAL` error, since globalinstalls (`npm install -g`) and one-off executions (`npm exec` / `npx`) haveno project `package.json` to write to. To allow install scripts in thosecontexts, use the `--allow-scripts` flag at install time (for example`npm install -g --allow-scripts=canvas,sharp`) or persist the setting with`npm config set allow-scripts=canvas,sharp --location=user`. There are four subcommands: ```bashnpm install-scripts approve <pkg> [<pkg> ...]npm install-scripts approve --allnpm install-scripts deny <pkg> [<pkg> ...]npm install-scripts deny --allnpm install-scripts lsnpm install-scripts prune``` `approve` allows install scripts for the named packages. `<pkg>` matchesevery installed version of that package. By default it writes pinned entries(`pkg@1.2.3`), which keep their approval narrowed to the specific version youreviewed. Pass `--no-allow-scripts-pin` to write name-only entries that allowany future version. `--all` approves every package with unreviewed installscripts in one go. `deny` records an explicit denial for the named packages (a name-only `false`entry), which survives `npm install-scripts approve --all` and excludes thepackage from any future blanket approval. `--all` denies every package withunreviewed install scripts. `ls` is read-only: it lists every package whose install scripts are not yetcovered by `allowScripts`, without modifying `package.json`. `prune` removes `allowScripts` entries that no longer match an installedpackage with an install script, either because the package is no longerinstalled (a transitive dependency changed, or a pinned `pkg@1.2.3` wasupgraded) or because it no longer has an install script. Both approvals(`true`) and denials (`false`) are removed. It edits only the `allowScripts`field in `package.json`, never `.npmrc` or `--allow-scripts`. Pass `--dry-run`to preview without writing. Unparseable keys are left alone. `approve` honours the asymmetric pin rule: if you re-approve a package whoseinstalled version has changed, the existing pin is rewritten to track the newinstalled version. Multi-version statements (`pkg@1 || 2`) are left alone,since they likely capture intent that the command cannot infer. Existing`false` entries always win; `approve` will not silently re-allow a package youpreviously denied. The standalone commands [`npm approve-scripts`](/commands/npm-approve-scripts)and [`npm deny-scripts`](/commands/npm-deny-scripts) are aliases for`npm install-scripts approve` and `npm install-scripts deny`. ### Examples ```bash# Approve all currently-installed install scripts after reviewing themnpm install-scripts approve --all # Approve specific packages, pinned to their installed versionnpm install-scripts approve canvas sharp # Deny a package so it stays blockednpm install-scripts deny telemetry-pkg # Preview which packages still need reviewnpm install-scripts ls # Preview stale allowScripts entries, then remove themnpm install-scripts prune --dry-runnpm install-scripts prune``` ### Configuration #### `all` * Default: false* Type: Boolean Show or act on all packages, not just the ones your project directly dependson. For `npm outdated` and `npm ls` this lists every outdated or installedpackage. For `npm approve-scripts` and `npm deny-scripts` it selects everypackage with pending install scripts.   #### `allow-scripts-pin` * Default: true* Type: Boolean Write pinned (`pkg@version`) entries when approving install scripts. Set to`false` to write name-only entries that allow any version. Has no effect on`npm deny-scripts`, which always writes name-only entries regardless of thissetting.   #### `dry-run` * Default: false* Type: Boolean Indicates that you don't want npm to make any changes and that it shouldonly report what it would have done. This can be passed into any of thecommands that modify your local installation, eg, `install`, `update`,`dedupe`, `uninstall`, as well as `pack` and `publish`. Note: This is NOT honored by other network related commands, eg `dist-tags`,`owner`, etc.   #### `json` * Default: false* Type: Boolean Whether or not to output JSON data, rather than the normal output. * In `npm pkg set` it enables parsing set values with JSON.parse() before  saving them to your `package.json`. Not supported by all npm commands.   ### See Also * [npm approve-scripts](/commands/npm-approve-scripts)* [npm deny-scripts](/commands/npm-deny-scripts)* [npm install](/commands/npm-install)* [npm rebuild](/commands/npm-rebuild)* [package.json](/configuring-npm/package-json)