【问题标题】:How to fix the problem with vue.js instalation如何解决 vue.js 安装问题
【发布时间】:2021-07-14 22:37:32
【问题描述】:

大家晚上好! 我正在尝试使用 npm 在我的 linux mint 上安装 vue.js。 当我运行 vue 教程中给出的简单命令时:

npm install -g @vue/cli

经过一些警告后,终端中出现以下错误:

 npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib' }
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!     and path to error log here

我明白,“操作被我的操作系统拒绝” 但我不知道如何解决它。如果有人帮我解决这个问题,我将不胜感激,因为我认为问题很简单

【问题讨论】:

    标签: vue.js npm linux-mint


    【解决方案1】:

    试试sudo npm install -g @vue/cli

    【讨论】:

    • 我已经试过id了。没有错误,但运行vue --version 给出以下输出bash: /snap/bin/vue: No such file or directory
    • 但是终端重启后终于可以用了,谢谢
    • sudonpm 一起使用是个坏主意。
    【解决方案2】:

    我在 stackoverflow 的另一个讨论中找到了另一个解决方案: npm throws error without sudo

    基本上发生的事情是 NPM 没有访问/usr/local/lib 的权限。要授予它访问权限,您可以更改 ~/.npm 的所有权以属于您当前的用户。可能是这样的:

    sudo chown -R $(whoami) ~/.npm

    这样您就不必将npm 作为 sudo 运行,这是不推荐的。我相信这是由于 npm 包中已知的漏洞造成的。

    这是一篇关于它的文章:Don't use "sudo" with npm "install"

    【讨论】:

      猜你喜欢
      • 2019-11-16
      • 2021-03-06
      • 1970-01-01
      • 1970-01-01
      • 2022-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-10
      相关资源
      最近更新 更多