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] install runs before preinstall on npm install #2883

Closed
CxRes opened this issue Mar 16, 2021 · 7 comments
Closed

[BUG] install runs before preinstall on npm install #2883

CxRes opened this issue Mar 16, 2021 · 7 comments
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release

Comments

@CxRes
Copy link

CxRes commented Mar 16, 2021

I have upgraded from npm v6 to npm v7 (for the third time) and almost immediately hit this bug!

Current Behavior:

If specified, preinstall script runs after install on npm install.

Expected Behavior:

Preinstall script should run before install.

Steps To Reproduce:

Create a preinstall script in package.json

{
  ...
  "scripts": {
    "preinstall": "echo FOOBAR"
  }
}

Run install

npm install

Environment:

  • OS: Windows 10 x64 10.0.19042
  • Node: 14.15.4
  • npm: 7.6.3
@CxRes CxRes added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Mar 16, 2021
@wraithgar
Copy link
Member

preinstall is a script that runs before the install script, not before the install action. This was discussed in a PR where we proposed changing it, but realized it would be a breaking change: #2713

The place to discuss new lifecycle events is the rfc process, and there is an issue where we have been discussing what this actual lifecycle event would need to be called: npm/rfcs#325

@wraithgar wraithgar removed the Needs Triage needs review for next steps label Mar 22, 2021
@CxRes
Copy link
Author

CxRes commented Mar 23, 2021

@wraithgar Thanks for pointing this out!

I must say the having separate install script and action is massively confusing. Could this issue be reopened as a documentation issue and behaviour be clearly documented.

For some reason I do not see this in v6? Was that intentional or a bug? Can this be noted as a breaking change!

@wraithgar
Copy link
Member

Clarifying the documentation is already a part of the RFC issue linked and is part of our backlog.

@CxRes
Copy link
Author

CxRes commented Mar 23, 2021

@wraithgar Also how would one run a script before install action?

@wraithgar
Copy link
Member

There is currently no lifecycle event that runs before the install action itself. This is one of the things being discussed in the rfc issue npm/rfcs#325, and might even need to be a separate issue or rfc. If you have a proposal, please submit one.

@CxRes
Copy link
Author

CxRes commented Mar 23, 2021

I need to think about this!!!! The behaviour I am observing seems different from what are being reported by others in these issues/rfcs....

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 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

3 participants