简体   繁体   English

每次我尝试使用 npm 做某事时都会出现 EACCES 错误

[英]EACCES error every time I try and do something with npm

Whenever I do anything related to npm, including uninstalling npm itself, I get this error:每当我做任何与 npm 相关的事情时,包括卸载 npm 本身,我都会收到此错误:

npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/bin/corepack
npm ERR! dest /usr/local/bin/.corepack-0KY6b4OJ
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/bin/corepack' -> '/usr/local/bin/.corepack-0KY6b4OJ'
npm ERR!  [Error: EACCES: permission denied, rename '/usr/local/bin/corepack' -> '/usr/local/bin/.corepack-0KY6b4OJ'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/usr/local/bin/corepack',
npm ERR!   dest: '/usr/local/bin/.corepack-0KY6b4OJ'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

This didn't use to be the case as I have had no issues in the past, although the last time I tried to use an npm-related command was about a year ago.过去并非如此,因为我过去没有遇到任何问题,尽管我最后一次尝试使用与 npm 相关的命令是大约一年前。

I've tried many solutions, including sudo, nvm and uninstalling Node completely but nothing seems to work.我尝试了许多解决方案,包括 sudo、nvm 和完全卸载 Node,但似乎没有任何效果。 I haven't used Node much before so I'm not very familiar with it unfortunately, so any help would be greatly appreciated.我以前没有太多使用过 Node,所以很遗憾我对它不是很熟悉,所以任何帮助都将不胜感激。

使用命令以administrator身份运行 npm 包

sudo npm install -g npm@latest

Turns out it was an issue with my antivirus software!原来是我的杀毒软件有问题! After disabling the software and installing NVM everything now works fine.禁用软件并安装 NVM 后,现在一切正常。

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

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