Delete the Global NPM Folder
https://stackoverflow.com/a/5926706/349659
npm list -g
For Windows this will most likely be:
%AppData%
pm
ode_modules
You can paste that into a folder's address bar and it will take you there.
Once there delete the folder named npm
.
Download the Latest Release of NPM
https://github.com/npm/cli/releases/latest
Grab the zip and unzip it to your node_modules
folder that you just deleted the npm folder from.
Rename the folder you extracted from the zip to npm
If you get any warnings about the file path or name being too long skip the warnings.
Update for Good Luck
Now you should be able to run npm i -g npm
to update/reinstall npm without any warnings.
I find this step especially important if you had errors in Windows about the path or file name being too long.
You may get the following errors. If you do go and delete or move the files it has listed and you should be able to run npm i -g npm
successfully.
npm ERR! Refusing to delete C:Program Files
odejs
px.cmd: is outside C:Program Files
odejs
ode_modules
pm and not a link
npm ERR! File exists: C:Program Files
odejs
px.cmd
npm ERR! Move it away, and try again.
npm ERR! Refusing to delete C:Program Files
odejs
pm.cmd: is outside C:Program Files
odejs
ode_modules
pm and not a link
npm ERR! File exists: C:Program Files
odejs
pm.cmd
npm ERR! Move it away, and try again.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…