npm --ignore-scripts - postinstall Skipped, Native Binary Missing
Disabling lifecycle scripts is good for supply-chain safety, but some packages need postinstall to compile native code or fetch a platform binary. Skip it and they appear installed yet fail when used.
What this error means
Install succeeds, but a package that needs a postinstall step (e.g. it downloads a binary or builds a native addon) is missing files and crashes at runtime - often "Cannot find module" for a .node file or a missing CLI binary.
# install ran with --ignore-scripts; later:
Error: Could not load the "sharp" module using the linux-x64 runtime
Possible solutions:
- Ensure optional dependencies can be installedCommon causes
ignore-scripts is set in .npmrc or the install flag
A global ignore-scripts=true (or npm ci --ignore-scripts) prevents postinstall from running, so packages that build or fetch artifacts at install time are left incomplete.
The package genuinely needs its postinstall
Native-addon and binary-wrapping packages do real work in postinstall. Without it, the runtime files never appear.
How to fix it
Allow scripts for the packages that need them
Run the install without globally disabling scripts, or re-run the needed build step explicitly.
# either install normally:
npm ci
# or, if you must keep ignore-scripts globally, rebuild the natives:
npm rebuild sharpBalance safety and correctness
- Prefer keeping scripts enabled for trusted dependency sets with a committed lockfile.
- If you disable scripts for security, run
npm rebuild(or the package’s install step) for native packages. - Audit which dependencies rely on postinstall before turning ignore-scripts on globally.
How to prevent it
- Know which deps need postinstall before disabling scripts.
- Pair --ignore-scripts with explicit npm rebuild for natives.
- Lock dependencies so enabling scripts stays safe.