Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] prepare script is ignored after npm install under production env #2152

Closed
jasonkarns opened this issue Nov 10, 2020 · 3 comments
Closed
Labels
Bug thing that needs fixing Release 6.x work is associated with a specific npm 6 release

Comments

@jasonkarns
Copy link
Contributor

Current Behavior:

npm install under "production" environment does not run prepare lifecycle hook

Expected Behavior:

prepare script should be invoked at all times

At the very least, the documentation should be updated to reflect this surprising/counter-intuitive behavior. Presently there is no hint that prepare-script behavior varies based on environment.

Steps To Reproduce:

  1. given npm script: "prepare": "echo hi"
  2. run npm i --production or NODE_ENV=production npm i
  3. note that "hi" is not echoed

Environment:

  • macOS
  • node 14
  • npm 6.14.8
@jasonkarns jasonkarns added Bug thing that needs fixing Needs Triage needs review for next steps Release 6.x work is associated with a specific npm 6 release labels Nov 10, 2020
@dimooze
Copy link

dimooze commented Jan 15, 2021

Hi @jasonkarns !
I think this is the expected behavior as it also mentioned in the doc see : https://docs.npmjs.com/cli/v6/using-npm/scripts#npm-install (prepare (when on local))

@jasonkarns
Copy link
Contributor Author

local is not a defined thing. If it were, that would imply that NODE_ENV=production npm i on a "local" machine, would also run the prepare hook; but it does not. What's more, if "local" is what drives the behavior, then running NODE_ENV=development npm i on a "remote" build or production box would presume that it does not run the prepare hook (because it's being run "not on local"). However, that is also not the case. Ergo, the phrase "when on local" is confusing and misleading. npm has no concept of what machine may be local or not, and that term is relative, anyway. Previously, prepare was documented as running for "bare installs" (ie, npm install, as opposed to npm install foo). So either the behavior is wrong in that it's being affected by the node environment; or it is the desired behavior and the docs should be updated to reflect that prepare is affected by node environment.

@darcyclarke
Copy link
Contributor

npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.

If your bug is preproducible on v7, please re-file this issue using our new issue template.

If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo

Closing: This is an automated message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Release 6.x work is associated with a specific npm 6 release
Projects
None yet
Development

No branches or pull requests

3 participants