vue-cli 3 安装没有权限 npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules

我们安装某个插件的时候,经常会遇到这样没有权限的报错:checkPermissions Missing write access to /usr/local/lib/node_modules(缺少对/usr/local/lib/node_modules的写访问权限),例如我下面的报错就是安装 vue-cli 3 产生的报错:

namedeMacBook-Pro:~ name$ npm install -g @vue/cli
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
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 (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/maramlee/.npm/_logs/2019-12-21T14_44_16_751Z-debug.log
maramdeMacBook-Pro:~ name$ sudo npm install -g @vue/cli

是因为文件没有root权限,运行语句前面加上 sudo,即可获得权限解决报错。

sudo npm install -g @vue/cli

你可能感兴趣的:(vue-cli 3 安装没有权限 npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules)