Safeguard
Developer Tools•

Should CI run npm with ignore-scripts? What it stops and what breaks

ignore-scripts stops npm running package scripts such as install hooks in CI installs. It cuts one attack path but breaks packages that need a build step.

Safeguard Security Team
3 min read

Often yes, with an allow plan for packages that need install scripts. Setting ignore-scripts to true makes npm skip the scripts defined in package.json files, including install hooks that malicious packages abuse. It breaks packages that compile native code or download binaries during install, so test before you switch.

What the setting does

The npm documentation says that when ignore-scripts is true, npm does not run scripts specified in package.json files. The default is false. Commands that exist to run a particular script, such as npm test, npm start and npm run-script, still run their intended script, but they do not run any pre or post scripts.

Why it matters in CI

A CI runner usually holds credentials: a registry token, cloud access, a deploy key. If a dependency, or a dependency of a dependency, runs code at install time, that code runs with those credentials in reach. Disabling install scripts removes that route for many package compromises, though not for code that runs when your app or tests import the package.

How to switch it on

You can pass the flag on the command line, or set it in project configuration.

npm ci --ignore-scripts

Then run your own build and test scripts explicitly, as separate steps.

What breaks

Package behaviorWith ignore-scripts
Pure JavaScript, no install hookWorks
Native addon compiled at installFails or is unusable until you rebuild it explicitly
Downloads a binary at installBinary is missing
Your own postinstall buildDoes not run, call it yourself

A workable plan

  1. Run the install with ignore-scripts in CI.
  2. List which dependencies fail and why.
  3. For each, decide: rebuild it explicitly in a later step you control, replace it, or accept the script after reading it.
  4. Keep the credentialed steps, such as publish and deploy, in separate jobs that never run an install of untrusted code.
  5. Inventory your dependencies so you know which ones have install hooks.

This is one layer. It does not stop a malicious package from running when your tests load it, which is why scanning and lockfile review still matter.

Try it yourself

Click through it at your own pace, or open it full screen. Look at direct versus transitive dependencies, since most install hooks come from the transitive ones.

Quick check

Does ignore-scripts stop all malicious packages?

No. It stops install-time scripts. Code that runs when the package is imported still runs.

Will npm test still work?

Yes. npm documents that it still runs its intended script, but not pre or post scripts.

Safeguard scans dependencies and generates SBOMs, and policies and gates can fail a pull request on findings. The free scan is a quick check.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.