Current Behavior:
npm uninstall -g <package> doesn't run the preuninstall script
Also, npm install -g <package> doesn't run the preuninstall script from the previously installed version of the same package
Installing a newer version of a global package does trigger preuninstall in v6
Expected Behavior:
npm uninstall -g <package> should run the preuninstall script
Steps To Reproduce:
Since npm7 removed console output for scripts during installation, so I echo something to a logfile instead.
- Create a package with these scripts:
{
"name": "testpackage",
"version":"0.0.1",
"scripts": {
"preinstall": "echo \"preinstall\" >> /logs/log.txt",
"preuninstall": "echo \"preuninstall\" >> /logs/log.txt"
}
}
- run
npm pack
- run
npm install -g ./testpackage-0.0.1.tgz
- run
npm install -g ./testpackage-0.0.1.tgz again (this should have triggered preuninstall for the previous installation)
- run
npm uninstall -g testpackage
- confirm that the text file in /logs/log.txt does in fact not contain any 'preuninstall' lines
Images:
In v7:

In v6:

Environment:
- OS: Windows 10
- Node: 15.14.0
- npm: 7.7.6
Current Behavior:
npm uninstall -g <package>doesn't run thepreuninstallscriptAlso,
npm install -g <package>doesn't run thepreuninstallscript from the previously installed version of the same packageInstalling a newer version of a global package does trigger
preuninstallin v6Expected Behavior:
npm uninstall -g <package>should run thepreuninstallscriptSteps To Reproduce:
Since npm7 removed console output for scripts during installation, so I echo something to a logfile instead.
npm packnpm install -g ./testpackage-0.0.1.tgznpm install -g ./testpackage-0.0.1.tgzagain (this should have triggeredpreuninstallfor the previous installation)npm uninstall -g testpackageImages:


In v7:
In v6:
Environment: