【问题标题】:Vue-Cli won't installVue-Cli 不会安装
【发布时间】:2019-04-27 11:43:26
【问题描述】:

我有节点 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

【问题讨论】:

    标签: node.js vue.js npm vue-cli vue-cli-3


    【解决方案1】:

    你正面临文件权限的问题。

    npm-g 参数表示“全局”,它会将这些文件安装在系统目录中,特别是在您的计算机/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'
    

    【讨论】:

    • 不要使用 -g 安装使用在没有全局 c:/> 的情况下安装 npm install @vue/cli
    【解决方案2】:

    所有你需要做的就是在它之前运行相同的命令 sudo,

    $ sudo npm install -g @vue/cli

    系统会提示您输入管理员密码。

    【讨论】:

      猜你喜欢
      • 2020-04-20
      • 2021-05-20
      • 2021-06-17
      • 2021-02-13
      • 2019-08-02
      • 2020-05-25
      • 2020-04-03
      • 2018-07-07
      • 2020-05-12
      相关资源
      最近更新 更多