Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
663 views
in Technique[技术] by (71.8m points)

node.js - Unable to update npm from 6.14.8 to 7.3; deleting npm.cmd, npx.cmd, and npm leads to more errors

I've been attempting to update my npm globally using the npm install -g npm command in Git Bash to keep it current with Angular 11 and Node.js version 15.5.0. I receive the following error:

npm ERR! code EEXIST
npm ERR! path C:Program Files
odejs
pm.cmd
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! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

I deleted the file from nodejs and attempted to install again, but received another error about the npx.cmd. I deleted that file, attempt installation, and received an error about the npm file.

npm ERR! code EEXIST
npm ERR! path C:Program Files
odejs
px.cmd
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! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! code EEXIST
npm ERR! path C:Program Files
odejs
pm
npm ERR! Refusing to delete C:Program Files
odejs
pm: is outside C:Program Files
odejs
ode_modules
pm and not a link
npm ERR! File exists: C:Program Files
odejs
pm
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

After deleting them and attempting to install npm again, Git Bash no longer finds npm. The installation never starts.

bash: /c/Program Files/nodejs/npm: No such file or directory

I tried to delete the npm file from my roaming folder in AppData, but received the following error:

npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:UsersYoga 2 MitchellAppDataRoaming
pm
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:UsersYoga 2 MitchellAppDataRoaming
pm'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

I've also tried the following at different times:

  • Delete node_modules and reinstall npm
  • Used npm 7.3.0's Git repository to create a new npm file (?) (I will need to find the suggestion online again to clarify/provide more specifics)
  • Clean caches
  • Uninstall and reinstall Angular 11 CLI and Node.js (tried for both LTS and Current version)

Nothing has worked so far. The second method I tried in the above list was able to update it to 6.14.10, but this attempt returned errors that seemed to affect Angular. I reverted everything to the original state to be safe. Please let me know if I can clarify anything else regarding my issue.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I connected with another developer about the errors I've been receiving. The following approach was suggested, and it works for fixing the problem for LTS: How to completely remove node.js from Windows

The LTS version allowed me to update to npm's 6.14.11, but when I tried this approach to install the Current version, it stayed 6.14.11. Hopefully, this approach helps others who are experiencing similar errors.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...