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] Downgrading to previous npm version deletes all global packages. #3671

Closed
1 task done
dtoch opened this issue Aug 20, 2021 · 1 comment
Closed
1 task done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release

Comments

@dtoch
Copy link

dtoch commented Aug 20, 2021

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Downgrading npm 7.21.0 to a previous 7.x version causes all global packages to be deleted.

Expected Behavior

Downgrading npm 7.21.0 to a previous 7.x version should not delete all global packages.

Steps To Reproduce

A. Installed a clean node 14.17.5 installation (https://nodejs.org/dist/v14.17.5/node-v14.17.5-win-x64.zip) on Windows 10 in c:\temp\node. To avoid side-effects :

  • no custom $HOME/.npmrc present (so will use default settings)
  • no %AppData%\Local\npm-cache and neither %AppData%\Roaming\npm-cache present

B. Then in a DOS shell:

$set PATH=c:\temp\node;%PATH% 

$node -v
v14.17.5

$npm -v
6.14.14

Until now OK.

C. Then I wanted to upgrade npm to the latest version (7.21.0):

Because npm update -g npm@latest does nothing and npm install -g npm@latest fails with "File exists: c:\temp\node\npm.cmd", I used following procedure to upgrade to npm@latest (based on https://try2explore.com/questions/10972799):

$cd c:\temp\node

$move npm npm-old
$move npm.cmd npm-old.cmd
$move npx npx-old
$move npx.cmd npx-old.cmd

$cd node_modules
$move npm npm-old
$cd npm-old\bin
$node npm-cli.js i -g npm@latest

$npm -v
7.21.0

Until now OK.

D. Now I wanted to downgrade npm to [email protected]:

$npm update -g [email protected]

removed 691 packages, and audited 1 package in 9s

found 0 vulnerabilities
The batch file cannot be found.

Result :

c:\temp\node\node_modules now completely empty! Also if I first would have installed other global packages (verdaccio, yeoman, ...), then they would also have disappeared from c:\temp\node\node_modules.

Above procedure was performed in a DOS shell but I also encountered the same issue in a Powershell 7 shell.

Environment

  • OS: Windows 10
  • Node: 14.7.5 (includes npm 6.14.14)
@dtoch dtoch 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 Aug 20, 2021
@lukekarrys
Copy link
Contributor

Closing as duplicate of #3175.

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

No branches or pull requests

2 participants