npm 7 runs lifecycle scripts in cache dir, INIT_CWD broken
@sungodtemple▲ 1 net votes
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.