What I Wanted to Do
Configure a build script to run before publishing, by calling it in
What Happened Instead
npm publish, due to a permission error the
prepublishOnly failed with the following error:
prepublishOnly: cannot run in wd @xxxxxt@xxxx npm run build (wd=xxxxxxx)
But instead of stopping there the publication continued and ended up publish a broken package as the built assets where not generated.
This problem happens only in the case of the
cannot run in wd error. If the
prepublishOnly scripts runs and fails, the error does stop the publication as expected.
See issue https://github.com/semantic-release/semantic-release/issues/956 for more details.
The permission error is difficult to reproduce…It seems environment specific.
The problem seems to come from here: https://github.com/npm/npm-lifecycle/blob/8fcaa21c580b09f5b9818920f6e29b63272e1975/index.js#L72
The code should log an error and call
reject, at least when running the
prepare lifecycle events. Not sure if there is cases where failing to run a script is not an error…