- 检查node和npm的版本
$ node -v
v12.18.1
$ npm -v
6.14.5
- 安装指定版本的angular CLI
$ npm install -g @angular/cli@1.6.3
- 安装过程中报错 -- errno:-13
- 解决方案:
- 清除npm的缓存
$ npm cache clean
- 由于 npm 5 使用了新的包管理模式,所以在升级之后,请先清空一下本地缓存
$ npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.
- 如何还没有解决问题,尝试下面的代码清除缓存
$ npm cache clear --force && npm install --no-shrinkwrap --update-binary
up to date in 0.297s
- 安装typeScript
$ npm install -g typescript typings
+ typescript@3.9.5
+ typings@2.1.1
added 184 packages from 100 contributors in 14.211s
- 重新安装angular CLI
$ npm install -g @angular/cli@1.6.3
+ @angular/cli@1.6.3
added 1054 packages from 699 contributors in 555.239s
- 检查angular版本
$ ng -v
$ npm install -g @angular-devkit/core
+ @angular-devkit/core@9.1.9
added 12 packages from 49 contributors in 2.128s
- 再次检查angular cli版本
$ ng -v
铛铛铛,安装成功了!!!