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

Installing any module via npm after node installation deletes npm #606

Open
aminomancer opened this issue Jan 28, 2021 · 10 comments
Open

Installing any module via npm after node installation deletes npm #606

aminomancer opened this issue Jan 28, 2021 · 10 comments

Comments

@aminomancer
Copy link

  • nvm 1.1.7
  • windows 10

Basically the steps are to install nvm, install the latest node, then npm i -g yarn or anything really. It successfully installs yarn but then npm disappears. The only module is now yarn so the npm command is missing. So I'd uninstall node with nvm and try again, but the same thing consistently happens. Tried reinstalling nvm, same thing. Tried installing different node versions, also to no avail. The STR are pretty simple so if this was affecting everyone I think it would have been more apparent. So maybe it's something wrong with my own environment, but it's not like I did anything unorthodox in the installation. Anyone familiar with this problem? Thanks

@davidgeary
Copy link

davidgeary commented Jan 29, 2021

Same here. I'm currently running on:

  • nvm 1.1.7
  • node 12.3.1
  • npm 6.9.0

and it all works as expected.

But I've just upgraded with nvm install latest, which installs node 15.7.0 and npm 7.4.3. If I then do nvm use 15.7.0 and npm install -g typescript@latest, I see

added 1 package, removed 252 packages, and audited 2 packages in 4s

found 0 vulnerabilities

Note the 252 packages removed. After that, the npm folder under %APPDATA%\nvm\v15.7.0\node_modules has been deleted.

I can't see any reports of issues like this in the npm repository, so not sure yet if this is a npm or nvm problem.

@sandramfdeveloper
Copy link

Like @davidgeary says, it happens, exactly that happens. I have also tried to update npm with the npm-windows-upgrade library as it is said somewhere in the documentation but it has not worked either

@aminomancer
Copy link
Author

Thanks for the info David, I tried 12.3.1 and it works. So I'm at least able to use npm again without hard installing a node version. As for me, npm-windows-upgrade didn't help either, I wouldn't expect it would. At first I didn't notice that it was counting the number of packages in npm that were uninstalled. But it's apparent by the # of modules removed that npm is literally uninstalling itself as if it was a dependency conflict, so it sounds like it's just a comically fatal regression of npm itself

@davidgeary
Copy link

FYI, just installed 14.15.4 (node's latest active LTS version) with npm 6.14.10, and it too is working fine.

@coreybutler
Copy link
Owner

Just to provide some insight: NVM4W doesn't touch npm at all during runtime. The only time NVM4W does anything with npm at all is during install/uninstall. It downloads/copies npm into the node directory and expects npm to do the rest.

That said, there have been issues with npm hard-coding paths and partial paths into the npm code base. It's usually a failure to respect symlinks. Historically, the npm team hasn't been very responsive to my inquiries about these kinds issues, so I haven't had much luck tracking down the root cause when these kinds of issues arise.

@davidgeary
Copy link

@coreybutler TBH, the fact that NVM4W works fine with 6.9.0 and 6.14.10 made me assume it was really an npm issue anyway (but I thought it worth adding my info here for the benefit of anyone else searching on this).

I've just logged an issue in the npm repository - #2593 - in the hope that someone there can shed more light on it.

@davidgeary
Copy link

Looks like it's an issue with npm.

A new version of node (15.8.0) was released a few days ago that now includes npm 7.5.1. Installing this with NVM4W works correctly, so I'm guessing something was fixed in 7.5.x

@aminomancer Can you try installing again with nvm install 15.8.0 (or presumably nvm install latest) and make sure it fixes it for you too?

@aminomancer
Copy link
Author

@davidgeary yeah, installing 15.8.0 on NVM4W works for me. great!

@DakotaWray2
Copy link

Updating @Vue/CLI -g seemed to overwrite all installed global packages including npm.
nvm uninstall 15.10.0 and reinstalling 'fixes' it but requires re-install of all previously installed global packages.

@nemanjatesic
Copy link

This issue is now happening with the current LTS version of node 16.13.0. When you try to do "npm update -g <any_package>" npm will just delete itself. I tested this for node versions of 17.1.0, 16.13.0, and 16.9.1 and the problem is there in all of those versions too. I tried going back to 14.16.1 and for that version it wouldn't delete itself. Do you guys have any plans on fixing this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants