XXXX@yyyy:~/桌面$ npm install npm-cli -g
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules’
npm ERR! [Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules’] {
npm ERR! errno: -13,
npm ERR! code: ‘EACCES’,
npm ERR! syscall: ‘mkdir’,
npm ERR! path: ‘/usr/local/lib/node_modules’
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/XXXX/.npm/_logs/2023-02-19T14_14_05_776Z-debug-0.log
XXXX@yyyy:~/桌面$ sudo npm install npm-cli -g
[sudo] XXXX 的密码:
added 3 packages, and audited 269 packages in 14s
31 vulnerabilities (1 low, 12 moderate, 13 high, 5 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run npm audit
for details.
XXXX@yyyy:~/桌面$
参考https://www.cnblogs.com/QQ2476127622/articles/11047429.html