Windows 10 Pro x64环境下Node.js安装及npm更新报错求助
Hey there, let's work through that npm update error you're running into. From the error log snippet you shared:
0 info it worked if it ends with ok
1 verbose cli [ 'Z:\Program\nodejs\node.exe', ...
This is usually tied to cache corruption or permission hiccups—even when running as admin, Windows can throw odd blocks. Here's what you can try step by step:
Clear the npm cache first
Corrupted cache files are the #1 cause of these update failures. Fire up your admin PowerShell and run:npm cache clean --force
This wipes out any cached packages that might be conflicting with the update.Retry the targeted update command
With the cache cleared, run the update command again in that elevated PowerShell window:npm install -g npm@5.8.0
Double-check you're still using admin rights—regular user sessions often hit hidden permission walls even if you think you're set up correctly.Manually replace the npm installation (if the above fails)
If the command line method doesn't work, this hands-on approach is reliable:- Open File Explorer and navigate to your Node.js install folder:
Z:\Program\nodejs - Delete the
npmandnpm.cmdfiles in the root directory - Go into the
node_modulessubfolder and delete thenpmfolder inside it - Grab the npm 5.8.0 source package, extract it, and copy the entire
npmfolder intoZ:\Program\nodejs\node_modules - From the extracted npm folder's
bindirectory, copynpmandnpm.cmdback to the root of your Node.js install folder
- Open File Explorer and navigate to your Node.js install folder:
Check your PowerShell execution policy
Sometimes a strict policy blocks npm's update scripts. Run this in admin PowerShell to adjust it:Set-ExecutionPolicy RemoteSigned
When prompted, typeYto confirm the change.
Once you've tried these steps, run npm -v in your PowerShell to confirm you're now on version 5.8.0.
内容的提问来源于stack exchange,提问作者Phrosen

