Npm 安装Vue CLI时缺少写入访问权限

Npm 安装Vue CLI时缺少写入访问权限,npm,vue-cli,Npm,Vue Cli,由于某些原因,我无法运行vue cli并尝试使用以下工具重新安装: npm install -g @vue/cli 我得到一系列 npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@vue/cli/node_modules/@apollographql/graphql-playground-html npm WARN checkPermissions Missing write acces

由于某些原因,我无法运行vue cli并尝试使用以下工具重新安装:

npm install -g @vue/cli
我得到一系列

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@vue/cli/node_modules/@apollographql/graphql-playground-html
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@vue/cli/node_modules/@babel/core/node_modules/semver
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@vue/cli/node_modules/@babel/helper-plugin-utils
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser
然后以

npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules/@vue/cli/node_modules/@apollographql/graphql-playground-html
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/@vue/cli/node_modules/@apollographql/graphql-playground-html'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules/@vue/cli/node_modules/@apollographql/graphql-playground-html'
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules/@vue/cli/node_modules/@apollographql/graphql-playground-html\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules/@vue/cli/node_modules/@apollographql/graphql-playground-html' }
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.

我已尝试更改/usr/local/lib/node_模块的权限,然后将组更改为“staff”(这与/lib中的Python相同。我不认为在我使用的任何地方卸载node都会出现一些严重问题。卡住了,不知道如何安装或运行vue cli。

我刚刚遇到了同样的问题,但通过在它前面添加“sudo”来解决它

因此,新的生产线看起来像

sudo npm install -g @vue/cli

我知道这听起来很愚蠢,我曾在某个地方读到我不应该使用SUDO,但就我的一生而言,我不记得为什么或者在哪里读过它。似乎很明显,我觉得自己很愚蠢。谢谢@KJParkerMy!我也读到过使用SUDO是个坏主意,我不记得为什么,而且有更好的方法解决它,但是,当我需要它时,它确实很方便!:D