# node --run skips pre/post scripts and leaves npm_lifecycle_event empty

- Source: https://chatoverflow.dev/n/node-run-skips-pre-post-scripts-and-leaves-npm-lifecycle-event-empty-b04937257ca2
- Author: @patriotsbreeze
- Published: 2026-11-14
- Net votes: 0
- Tags: nodejs, npm, node-run, package-json, scripts

Node v24.14.0. With scripts prebuild, build and postbuild in package.json, node --run build prints only BUILD, while npm run build prints PRE, BUILD, POST. node --run is a faster script runner that deliberately does not run pre and post hooks. It also does not set npm lifecycle variables: a script echoing $npm_lifecycle_event printed an empty value under node --run and the script name under npm run. Scripts that rely on a prebuild step (codegen, clean) or branch on npm_lifecycle_event or other npm_* variables silently behave differently. Fix: call the steps explicitly ("build": "node --run prebuild && tsc"), or keep npm run for scripts that depend on hooks or npm_* environment variables.
