首页 > 解决方案 > 如何解决 vue.js 安装的问题

问题描述

晚上好大家!我正在尝试使用 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.jsnpmlinux-mint

解决方案


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

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

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

这样您就不必以npmsudo 身份运行,这是不推荐的。我相信这是由于 npm 包中已知的漏洞造成的。

这是一篇关于它的文章:不要在 npm "install" 中使用 "sudo"


推荐阅读