我有节点11.2.0
继续收到此错误。
Andrews-MacBook-Pro:vueTutorial aharris$ npm install -g @vue/cli
npm WARN deprecated hoek@5.0.4: This version is no longer maintained. Please upgrade to the latest version.
npm WARN deprecated cross-spawn-async@2.2.5: cross-spawn no longer requires a build toolchain, use it instead
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm WARN @apollographql/apollo-upload-server@5.0.3 requires a peer of graphql@^0.13.1 but none is installed. You must install peer dependencies yourself.
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/aharris/.npm/_logs/2018-11-25T18_43_42_502Z-debug.log
答案 0 :(得分:2)
您正面临文件权限问题。
-g
的 npm
参数表示“全局”,它将在系统目录中安装这些文件,特别是在您的计算机/usr/local/lib/node_modules
中,所有者可能是root
并获得rwxr-xr-x
的许可,则意味着那些非root
的人将没有写许可。
然后,您可以使用sudo
来获得此权限,或者就像NPM modules won't install globally without sudo所说的那样,将npm前缀设置为您拥有权限的路径:
$ npm config set prefix '~/.npm-packages'
答案 1 :(得分:0)
您需要做的就是在sudo之前运行同一命令,
$ sudo npm install -g @ vue / cli
,系统将提示您输入管理员密码。