简体   繁体   中英

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 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.

I've tried many solutions, including sudo, nvm and uninstalling Node completely but nothing seems to work. I haven't used Node much before so I'm not very familiar with it unfortunately, so any help would be greatly appreciated.

使用命令以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.

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