如何解决ubunu中的Angular CLI安装错误-尝试在ubuntu机器中运行Angular CLI命令时出现错误
我遇到此错误。 我已经在系统中安装了节点js和npm。 我也有删除npm缓存。
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
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: '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.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2020-11-03T18_21_04_293Z-debug.log
~~~
解决方法
不要使用 sudo
解决这个问题。按照在 Ubuntu 中使用的方式使用 sudo
:对于需要它的每个命令,仅此而已。不要使用 sudo
来运行命令,除非它需要是 root。例如,大多数用户只需要 sudo
即可安装。
你试过了吗,manually change npm's default directory?
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
source ~/.profile
要测试您的新配置,请在不使用 sudo
的情况下全局安装软件包:
npm install -g @angular/cli
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。