ubuntu中的Angular CLI安装错误-当我试图在我的ubuntu机器中运行Angular CLI命令时,我遇到



我得到了这个错误。我已经在我的系统中安装了node-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

你试过手动更改npm的默认目录吗?

mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
source ~/.profile

要测试您的新配置,请在不使用sudo:的情况下全局安装软件包

npm install -g @angular/cli

相关内容

  • 没有找到相关文章

最新更新