NPM-INSTALL-SCRIPTS(1)
π NAME π
npm-install-scripts β bestie's whole job is managing install-script approvals for your dependencies π«Ά
β¨ Synopsis β¨
npm install-scripts approve <pkg> [<pkg> ...]
npm install-scripts approve --all
npm install-scripts deny <pkg> [<pkg> ...]
npm install-scripts deny --all
npm install-scripts ls
npm install-scripts prune
Heads up babes: this command is unaware of workspaces. Like, it literally does not know they exist π
πΈ Description πΈ
Okay so here's the vibe. This command manages the allowScripts field in your project's package.json β that's the field that records which of your dependencies are permitted to run install scripts (preinstall, install, postinstall, and prepare for non-registry sources). And fr fr, this is the recommended way to maintain that field π
Dependency install scripts are blocked by default. Install commands silently skip lifecycle scripts for any dependency that doesn't have a matching entry in allowScripts, and they end with a list of the packages whose scripts were skipped so you can review them here π
This command only works inside a project that has a package.json. Running it with --global (-g) fails with an EGLOBAL error, since global installs (npm install -g) and one-off executions (npm exec / npx) have no project package.json to write to. To allow install scripts in those contexts, 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:
npm install-scripts approve <pkg> [<pkg> ...]
npm install-scripts approve --all
npm install-scripts deny <pkg> [<pkg> ...]
npm install-scripts deny --all
npm install-scripts ls
npm install-scripts prune
approveβ allows install scripts for the named packages.<pkg>matches every installed version of that package. By default it writes pinned entries (pkg@1.2.3), which keep their approval narrowed to the specific version you reviewed π Pass--no-allow-scripts-pinto write name-only entries that allow any future version. And--allapproves every package with unreviewed install scripts in one go πdenyβ records an explicit denial for the named packages (a name-onlyfalseentry), which survivesnpm install-scripts approve --alland excludes the package from any future blanket approval π«--alldenies every package with unreviewed install scripts.lsβ read-only, bestie. It lists every package whose install scripts are not yet covered byallowScripts, without modifyingpackage.json. Iconic behaviour honestly π¦pruneβ removesallowScriptsentries that no longer match an installed package with an install script, either because the package is no longer installed (a transitive dependency changed, or a pinnedpkg@1.2.3was upgraded) or because it no longer has an install script. Both approvals (true) and denials (false) are removed. It edits only theallowScriptsfield inpackage.json, never.npmrcor--allow-scripts. Pass--dry-runto preview without writing. Unparseable keys are left alone π§
approve honours the asymmetric pin rule: if you re-approve a package whose installed version has changed, the existing pin is rewritten to track the new installed 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 you previously denied π₯
The standalone commands npm help approve-scripts and npm help deny-scripts are aliases for npm install-scripts approve and npm install-scripts deny π
π Examples π
# Approve all currently-installed install scripts after reviewing them
npm install-scripts approve --all
# Approve specific packages, pinned to their installed version
npm install-scripts approve canvas sharp
# Deny a package so it stays blocked
npm install-scripts deny telemetry-pkg
# Preview which packages still need review
npm install-scripts ls
# Preview stale allowScripts entries, then remove them
npm install-scripts prune --dry-run
npm install-scripts prune
β Configuration β
π all
- Default:
false - Type:
Boolean
Show or act on all packages, not just the ones your project directly depends on. For npm outdated and npm ls this lists every outdated or installed package. For npm approve-scripts and npm deny-scripts it selects every package 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 this setting π
π dry-run
- Default:
false - Type:
Boolean
Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands 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, egdist-tags,owner, etc. π
π¦ json
- Default:
false - Type:
Boolean
Whether or not to output JSON data, rather than the normal output π
- In
npm pkg setit enables parsing set values withJSON.parse()before saving them to yourpackage.json.
Not supported by all npm commands π«Ά
π See Also π
npm help approve-scriptsnpm help deny-scriptsnpm help installnpm help rebuildpackage.json β¨/configuring-npm/package-jsonβ©
Okay that's the whole page bestie, go forth and approve responsibly π
β¨ β this was NPM@12.2.1, dated October 2026, and yes the man page name is NPM-INSTALL-SCRIPTS(1) in case you were wondering ππ«Ά
π¦ where this page comes from
- arch rolling: npm 12.2.1-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms