npm 5.4.1 install/uninstall all failing

2019-07-13 23:19发布

问题:

I am on Windows 10. I upgraded my npm by doing a npm i -g npm.

However no package is installing or uninstallating. On install it is hanging always on postinstall like this:

PS C:\Users\Mercurius\Documents\GitHub\catchem-front> npm i --save immutable [ ......] \ postinstall: info lifecycle immutable@3.8.1~postinstall: > immutable@3.8.1

Here is a screenshot:

On uninstall it hangs/fails on:

PS C:\WINDOWS\system32> cd C:\Users\Mercurius\Documents\GitHub\catche PS C:\Users\Mercurius\Documents\GitHub\catchem-front> npm un --save c [ ......] \ postinstall: sill doSerial postinstall 894

This was me trying to run it as administrator in powershell, but same problem. It ends up giving me some unlink error and tells me to try admin mode:

I then got npm-windows-upgrade and followed here - https://stackoverflow.com/a/31520672/1828637

I even downloaded the latest node msi installer and upgraded to 8.5 but still getting this hang on postinstall..

However still having this issue. I think I used npm-windows-upgrade a long time ago, and they warn not to use npm i -g npm anymore, which I just found out, do you think this is the issue?

回答1:

NPM 5.4.0 and 5.4.1 have issues, You have 2 options one is to downgrade the current version

npm i -g npm@5.3.0

or the following which is to re-install with --no-optional flag which will prevent optional dependencies from being installed which seems to be the problem,

npm i -g npm@5.3.0
npm cache clean --force
npm install --no-optional

First method will work, second I have not tried it but should work theoretically.



标签: node.js npm