The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
package-lock.json not created when postinstall script fails
I’m seeing some behaviour from npm cli that I haven’t encountered before / can’t find it in the docs and makes me wonder:
When running npm install with package-lock not present, in the case of a postinstall script failing, I’m seeing that package-lock.json is not generated.
Has anyone seen this / is this expected?
run npm run nuke
ζ node -v ; npm -v
I’m seeing this both in linux and windows
I don’t know if that’s intended or not, but yeah,
saveDependencies (which calls
saveShrinkwrap) is only called after
runPostinstallTopLevelLifecycles (which runs the script):
This also has the consequence there’s no
package-lock.json when the postinstall script is run. Normally I’d make a PR at this point, but:
- I don’t think I’m
allowedsupposed to move around the install steps yet, given the completely uncontained nature and all the side effects, and
- again, this may be intended behaviour (it’s been this way forever, looking through the git history).
Somewhat relevant GH issues:
Thank you very much for the detailed reply, Lars.
I’ll adjust my package.json scripts so that post install doesn’t fail and put the part that can fail in another script.