删除全局NPM文件夹
https://stackoverflow.com/a/5926706/349659
npm list -g
对于Windows,这很可能是:
%AppData%npmnode_modules
您可以将其粘贴到文件夹的地址栏中,它将带您到那里。
在那里,删除名为的文件夹
npm。
下载最新版本的NPM
https://github.com/npm/cli/releases/latest
抓取zip并将其解压缩到
node_modules刚从中删除npm文件夹的文件夹中。
将您从zip提取的文件夹重命名为
npm
如果您收到有关文件路径或名称太长的任何警告,请跳过警告。
更新祝你好运
现在,您应该能够在
npm i -g npm没有任何警告的情况下运行更新/重新安装npm。
如果您在Windows中遇到有关路径或文件名过长的错误,我认为此步骤特别重要。
您可能会遇到以下错误。如果确实要删除并移动列出的文件,则应该可以
npm i -g npm成功运行。
npm ERR! Refusing to delete C:Program Filesnodejsnpx.cmd: is outside C:Program Filesnodejsnode_modulesnpm and not a linknpm ERR! File exists: C:Program Filesnodejsnpx.cmdnpm ERR! Move it away, and try again.npm ERR! Refusing to delete C:Program Filesnodejsnpm.cmd: is outside C:Program Filesnodejsnode_modulesnpm and not a linknpm ERR! File exists: C:Program Filesnodejsnpm.cmdnpm ERR! Move it away, and try again.



