(I was using npm 8.3.1 at first, updated to 8.12.1 and issue persisted)
I wanted to update a package I am using called mlogx.
I mistyped the command as npm up -g mlog
I did not want to install a random package, so I pressed Ctrl+C and told windows not to terminate the batch job.
Several seconds after I pressed Ctrl+C npm outputs "Removed 1426 packages."
Everything's gone.
I'm pretty sure you're not supposed to ctrl+c npm, but uninstalling all packages is the worst thing that can happen short of a vulnerability.
Expected Behavior
Either terminate/abort the command or install/update the mlog package.
Steps To Reproduce
Run npm up -g (some package that you don't have installed)
Quickly press Ctrl+C and then type n
It removes all your globally installed packages. Reproduced twice.
Environment
npm: 8.12.1
Node.js: 16.14.0
OS Name: Windows
System Model Name: Lenovo Flex 14API
npm config:
; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc
; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Bala\Mindustry\logic
; HOME = C:\Users[username]
; Run npm config ls -l to show all defaults.
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
(I was using npm 8.3.1 at first, updated to 8.12.1 and issue persisted) I wanted to update a package I am using called mlogx. I mistyped the command as
npm up -g mlog
I did not want to install a random package, so I pressed Ctrl+C and told windows not to terminate the batch job. Several seconds after I pressed Ctrl+C npm outputs "Removed 1426 packages." Everything's gone.I'm pretty sure you're not supposed to ctrl+c npm, but uninstalling all packages is the worst thing that can happen short of a vulnerability.
Expected Behavior
Either terminate/abort the command or install/update the
mlog
package.Steps To Reproduce
Run
npm up -g (some package that you don't have installed)
Quickly press Ctrl+C and then type nIt removes all your globally installed packages. Reproduced twice.
Environment
prefix = "C:\Users\[username]\AppData\Roaming\npm"
; "user" config from C:\Users[username].npmrc
//registry.npmjs.org/:_authToken = (protected)
; node bin location = C:\Program Files\nodejs\node.exe ; cwd = C:\Bala\Mindustry\logic ; HOME = C:\Users[username] ; Run
npm config ls -l
to show all defaults.