简体   繁体   English

如何执行 NPM 的全新安装

[英]How to perform a clean install of NPM

Every time I try to run npm on Windows 10, I get Error: EINVAL: invalid argument, mkdir 'C:\Program Files\nodejs"'每次我尝试在 Windows 10 上运行 npm 时,我都会收到Error: EINVAL: invalid argument, mkdir 'C:\Program Files\nodejs"'

  • I have deleted %Appdata%\npm and %Appdata%\npm-cache .我已删除%Appdata%\npm%Appdata%\npm-cache
  • I have deleted c:\program files\nodejs , checked that c:\program files (x86)\nodejs does not exist, and tried to install NodeJS in c:\nodejs instead to get rid of the space in the directory name. I have deleted c:\program files\nodejs , checked that c:\program files (x86)\nodejs does not exist, and tried to install NodeJS in c:\nodejs instead to get rid of the space in the directory name.
  • I have uninstalled NodeJS and searched through the Windows registry, removing every reference to NodeJS.我已经卸载了 NodeJS 并搜索了 Windows 注册表,删除了对 NodeJS 的所有引用。
  • I have tried to use NPM to update NPM to a different version, but I only get the same error.我尝试使用 NPM 将 NPM 更新到不同的版本,但我只得到相同的错误。
  • I have removed all references to Node folders from environment variables and paths.我已经从环境变量和路径中删除了对节点文件夹的所有引用。
  • Of NodeJS versions I have tried Latest LTS Version: 12.16.3 (includes npm 6.14.4 ), and Latest Current Version: 14.2.0 (includes npm 6.14.4 ).在 NodeJS 版本中,我尝试过最新的LTS 版本:12.16.3 (包括npm 6.14.4 )和最新的当前版本:14.2.0 (包括npm 6.14.4 )。
  • I have tried using Chocolatey to install NodeJS, it made no difference.我曾尝试使用 Chocolatey 安装 NodeJS,它没有任何区别。

Every time I reboot, reinstall NodeJS, and try to use NPM, I get the same error.每次我重新启动、重新安装 NodeJS 并尝试使用 NPM 时,我都会收到相同的错误。

When I try to check what version of NPM is actually installed, the answer is... the same error.当我尝试检查实际安装的 NPM 版本时,答案是......同样的错误。

How do I eradicate all NodeJS and NPM related files and settings from Windows 10 so that I can perform an actual clean install, without having to resort to the nuclear option, formatting the drive and reinstalling Windows?如何从 Windows 10 中删除所有与 NodeJS 和 NPM 相关的文件和设置,以便我可以执行实际的全新安装,而无需求助于核选项,格式化驱动器并重新安装 ZAEA23489CE3AA9B64006EBB28E0CDA43

Ok, after ripping my hair out, as well as half of the installed software on my PC, I continued googling, and eventually stumbled on the solution by investigating some file paths mentioned in this question: nodejs npm global config missing on windows .好的,在撕掉我的头发以及我电脑上安装的一半软件之后,我继续谷歌搜索,最终通过调查这个问题中提到的一些文件路径偶然发现了解决方案: nodejs npm global config missing on windows

Apparently, there is a config file %userprofile%\.npmrc which is relevant somehow.显然,有一个配置文件%userprofile%\.npmrc以某种方式相关。 On my own computer, this file contained the text prefix=C:\Program Files\nodejs" .在我自己的计算机上,此文件包含文本prefix=C:\Program Files\nodejs"

If that looks familiar, it's because it's the string in the error message that has been plaguing me.如果这看起来很熟悉,那是因为一直困扰我的是错误消息中的字符串。 When I emptied the file, npm started working again, just like that.当我清空文件时,npm 又开始工作了,就这样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM