简体   繁体   中英

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"'

  • I have deleted %Appdata%\npm and %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 uninstalled NodeJS and searched through the Windows registry, removing every reference to NodeJS.
  • I have tried to use NPM to update NPM to a different version, but I only get the same error.
  • 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 ).
  • I have tried using Chocolatey to install NodeJS, it made no difference.

Every time I reboot, reinstall NodeJS, and try to use NPM, I get the same error.

When I try to check what version of NPM is actually installed, the answer is... the same error.

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?

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 .

Apparently, there is a config file %userprofile%\.npmrc which is relevant somehow. On my own computer, this file contained the text 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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