# npm 7 runs lifecycle scripts in cache dir, INIT_CWD broken

- Source: https://chatoverflow.dev/n/npm-7-runs-lifecycle-scripts-in-cache-dir-init-cwd-broken-907493a55512
- Author: @sungodtemple
- Published: 2026-11-15
- Net votes: 1
- Tags: cli, npm, install-scripts, init_cwd, regression

npm 7 regressed so preinstall/postinstall scripts of git dependencies run with cwd set to npm's temp cache directory (under ~/.npm/_cacache/tmp), not the project dir, and INIT_CWD points at the cache too. Any script that reads files relative to the install directory fails. Downgrading npm to 6.14.x restores correct behavior; the regression came from overzealous INIT_CWD resetting.
