【问题标题】:Angular installation failure in Ubuntu 16.04 (Xenial Xerus)Ubuntu 16.04(Xenial Xerus)中的角度安装失败
【发布时间】:2018-11-25 10:21:41
【问题描述】:

Angular CLI 在运行安装命令时总是显示错误,而且ng 显示找不到这样的命令。我该如何解决这个问题?

shivashish-Inspiron-3521% cd Angular-project
shivashish-Inspiron-3521% ls
shivashish-Inspiron-3521% sudo npm install -g angular/cli
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/angular/cli.git
npm ERR!
npm ERR! Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/shivashish/.npm/_logs/2018-11-25T10_01_17_050Z-debug.log
shivashish-Inspiron-3521% ls
shivashish-Inspiron-3521% ng new app
zsh: command not found: ng
shivashish-Inspiron-3521% node -v
v8.13.0

我再次运行,现在我得到了这个:

shivashish-Inspiron-3521% npm install -g @angular/cli
npm WARN checkPermissions Missing write access to /usr/lib/node_modules
npm ERR! path /usr/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR!  { Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/usr/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/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 (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/shivashish/.npm/_logs/2018-11-25T13_53_57_814Z-debug.log

【问题讨论】:

  • 我改成@angular还是一样的问题。
  • 你好,请仔细阅读我的回答;您还需要使用sudo 否则您将遇到权限问题

标签: installation angular-cli ubuntu-16.04


【解决方案1】:

这是因为它应该是 @angular/cli 而不是 angular/cli。正确的命令是:

sudo npm install -g @angular/cli

根据Step 1: Install the Angular CLI

PS:在linux

上全局安装(-g参数)时请不要忘记使用sudo

【讨论】:

  • 我改了,同样的问题又出现了。
  • 嗯,谢谢;请为您的帖子创建一个更新部分,以便打印新日志。我目前的回答确实适合您目前的情况,所以我建议单独更新部分,谢谢
  • 我注意到更新的错误日志显示命令前面不再使用sudo;这就是权限问题。
猜你喜欢
  • 2017-12-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-10
  • 2019-06-17
相关资源
最近更新 更多