【问题标题】:I am not able to install Angular/Cli onto my ubuntu 18 system我无法将 Angular/Cli 安装到我的 ubuntu 18 系统上
【发布时间】:2020-05-31 10:25:27
【问题描述】:

我正在尝试将 Angular/CLI 安装到我的 Ubuntu 系统上。

Ubuntu 18.04.4 LTS 64 位

 node -v


npm -v

npm 版本是 3.5.2

npm install -g @angular/cli

我已经安装了 Node 并且它的显示版本为 v8.10.0 但是当我尝试安装 Angular/cli 时它显示了一些错误,如下所示

 npm install -g @angular/cli
- |---------------------------------------------------------------------------|
WARN engine @angular/cli@9.0.2: wanted: {"node":">= 10.13.0","npm":">= 6.11.0","yarn":">= 1.13.0"} (current: {"node":"8.10.0","npm":"3.5.2"})
WARN engine @angular/cli@9.0.2: wanted: {"node":">= 10.13.0","npm":">= 6.11.0","loadDep:uuid -> get       / |##########---------------------------------------|
WARN engine @angular-devkit/architect@0.900.2: wanted: {"node":">= 10.13.0","npmloadDep:uuid -> get       - |##########---------------------------------------|
WARN engine @angular-devkit/core@9.0.2: wanted: {"node":">= 10.13.0","npm":">= 6.11.0","yarn":">= 1.13.0"} (current: {"node":"8.10.0","npm":"3.5.2"})
WARN engine @angular-devkit/schematics@9.0.2: wanted: {"node":">= 10.13.0","npm"loadDep:uuid -> get       | |##########---------------------------------------|
WARN engine @schematics/angular@9.0.2: wanted: {"node":">= 10.13.0","npm":">= 6.loadDep:uuid -> network   | |##########---------------------------------------|
WARN engine @schematics/update@0.900.2: wanted: {"node":">= 10.13.0","npm":">= 6npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@angular/cli
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@angular
/usr/local/lib
`-- @angular/cli@9.0.2 

npm ERR! Linux 5.3.0-28-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "@angular/cli"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! path /usr/local/lib/node_modules/@angular/cli
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/@angular/cli'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules/@angular/cli'
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules/@angular/cli' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/sagar/npm-debug.log
sagar@sagar-HP-Notebook:~$ ng -v
Node.js version v8.10.0 detected.
The Angular CLI requires a minimum Node.js version of either v10.13 or v12.0.


 ng -v

Node.js version v8.10.0 detected.
The Angular CLI requires a minimum Node.js version of either v10.13 or v12.0.

谁能帮我摆脱这个错误。

【问题讨论】:

标签: node.js angular ubuntu npm angular-cli


【解决方案1】:

似乎您的 NodeJS 版本与您的 Angular CLI 版本不兼容。查看Angular CLI/Angular/NodeJS/Typescript 兼容性详情here

另外我建议使用NVM 来管理 NodeJS - 这样您就可以轻松地在 NodeJS 版本之间切换。

【讨论】:

    【解决方案2】:

    试试这个:

      sudo npm uninstall -g @angular/cli
      sudo npm cache clean --force
      sudo npm install --force -g @angular/cli
    

    为我工作!

    【讨论】:

      【解决方案3】:

      你没有创建目录的写权限,试试看:

      sudo npm install -g @angular/cli
      

      【讨论】:

      • 我用过这个命令但是sudo npm install -g @angular/cli还是同样的问题
      • 检测到 Node.js 版本 v11.15.0。 Angular CLI 需要 v10.13 或 v12.0 的最低 Node.js 版本。
      【解决方案4】:

      我遇到了同样的问题:

      解决方案很简单: 依次运行以下命令。

      1. sudo npm cache clean -f
      2. sudo npm install -g n
      3. sudo n 稳定

      之后运行以下命令来创建您的新项目。

      新的

      如果仍有问题,只需关闭终端并重新打开即可。

      你可以走了!!!!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-08-04
        • 2020-09-28
        • 2018-08-06
        • 2017-04-04
        • 1970-01-01
        • 2019-01-05
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多