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

"npm update" deletes npm itself #2014

Closed
michaelestermann opened this issue Oct 22, 2020 · 3 comments
Closed

"npm update" deletes npm itself #2014

michaelestermann opened this issue Oct 22, 2020 · 3 comments
Assignees
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release

Comments

@michaelestermann
Copy link

We've updated our node installation from the latest 14 version to the current version 15.0.1.
After updating and executing the "npm update" command, the npm folder gets deleted.

In our environment, we've included the node standalone installation (along with npm) in our git repository. The package.json is located in the same directory as the node executable. Therefor its not the same situation as described in this issue npm/npm#5050.

I just created a repro here: https://github.com/michaelestermann/NpmUpdateRepro

Current Behavior:

When executing npm update in the described environment above. The npm folder in the node_modules directory gets deleted.

Expected Behavior:

It should ignore the npm folder.

Steps To Reproduce:

  1. Clone the repro from https://github.com/michaelestermann/NpmUpdateRepro
  2. Execute npm update

Environment:

  • OS: Windows 10 (Version 2004)
  • Node: 15.0.1
  • npm: 7.0.3
@michaelestermann michaelestermann 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 Oct 22, 2020
@Mys73rion
Copy link

We tried again to update, now with version 15.1.0, and we still have the same issue.

@nlf nlf removed the Needs Triage needs review for next steps label Nov 30, 2020
@nlf nlf self-assigned this Nov 30, 2020
@nlf
Copy link
Contributor

nlf commented Nov 30, 2020

this is the intended behavior.

when npm attempts to turn your requested package dependencies into reality part of that process involves removing packages that are not required. you can see this in your repo if you run npm ls, example output is below (ignore the UNMET DEPENDENCY lines, i cloned the repo and ran npm ls without installing anything so those are expected)

> npm ls
npmupdaterepro@1.0.0 C:\Users\Nathan LaFreniere\Projects\NpmUpdateRepro
├── UNMET DEPENDENCY eslint-plugin-jquery@1.5.1
├── UNMET DEPENDENCY eslint@7.10.0 deduped
├── npm@7.0.3 extraneous
├── UNMET DEPENDENCY stylelint-checkstyle-formatter@0.1.2 deduped
├── UNMET DEPENDENCY stylelint-config-recommended@3.0.0 deduped
├── UNMET DEPENDENCY stylelint-config-standard@20.0.0 deduped
├── UNMET DEPENDENCY stylelint@13.7.2 deduped
└── UNMET DEPENDENCY uglify-es@3.3.9 deduped

above you'll note the line that tells us that npm@7.0.3 is extraneous, this means that the next time we try to resolve your dependencies it will be removed.

you can correct this by adding npm itself to your package.json's dependencies field like "npm": "7.0.3"

a repeated run of npm ls shows that it is no longer marked as extraneous:

> npm ls
npmupdaterepro@1.0.0 C:\Users\Nathan LaFreniere\Projects\NpmUpdateRepro
├── UNMET DEPENDENCY eslint-plugin-jquery@1.5.1
├── UNMET DEPENDENCY eslint@7.10.0 deduped
├── npm@7.0.3
├── UNMET DEPENDENCY stylelint-checkstyle-formatter@0.1.2 deduped
├── UNMET DEPENDENCY stylelint-config-recommended@3.0.0 deduped
├── UNMET DEPENDENCY stylelint-config-standard@20.0.0 deduped
├── UNMET DEPENDENCY stylelint@13.7.2 deduped
└── UNMET DEPENDENCY uglify-es@3.3.9 deduped

and running npm update no longer removes it.

@myudak
Copy link

myudak commented Jul 27, 2024

i still running into this issue

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

4 participants