mac安装vue-cli的时候出现Error: EACCES: permission denied, access '/usr/local/lib/node_modules错的解决办法。


pm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules/vue-cli/node_modules/ansi-escapes
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/vue-cli/node_modules/ansi-escapes'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules/vue-cli/node_modules/ansi-escapes'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules/vue-cli/node_modules/ansi-escapes'
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.

原因: 权限不足。
解决办法: 在命令行前面添加sudo获取管理员权限,输入管理员密码就行sudo npm install -g vue-cli

Last modification:October 24, 2020
If you think my article is useful to you, please feel free to appreciate