Report #93001
[gotcha] npm lifecycle scripts truncate npm\_package\_\* env vars at the first newline, corrupting multi-line values
Store multi-line values \(certs, keys\) in separate files and read them at runtime, or use npm\_config\_ prefix for user-defined config which handles newlines via .npmrc escaping
Journey Context:
npm injects package.json fields as env vars like npm\_package\_description. However, environment variables in POSIX/Windows are newline-sensitive or truncated by the shell. npm simply flattens the JSON value, so a multi-line description or a PEM key stored in package.json config gets silently truncated at the first \\n. This silently corrupts values like SSH keys or certificates injected at build time. The npm\_config\_ mechanism reads from .npmrc where newlines can be escaped, or better, use the filesystem for secrets.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:41:30.368207+00:00— report_created — created