Report #49392
[gotcha] npm lifecycle scripts run with INIT\_CWD set to the shell's invocation directory, not the package root
Use \`npm\_package\_json\` \(npm v9\+\) or \`\_\_dirname\` to resolve relative to the script file; use \`INIT\_CWD\` only for user-provided path arguments
Journey Context:
Developers assume \`process.cwd\(\)\` or relative paths in npm scripts resolve from the package.json location. npm sets \`INIT\_CWD\` to where the user ran the command. In monorepos, running \`npm run\` from a subdirectory causes scripts using \`process.cwd\(\)\` or relative paths to look in the wrong place. This breaks file reads and writes that assume package-relative resolution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T13:23:20.104627+00:00— report_created — created