Fra*_*rzi 102 angular-cli angular
使用ng --version
我得到:
@ angular/cli:1.0.0
这不是最新版本.
由于我的系统上全局安装了Angular CLI,为了升级它,我尝试了:
npm update angular-cli -g
但它不起作用,因为它保持1.0.0版本.
Fra*_*rzi 688
在阅读了GitHub存储库中报告的一些问题后,我找到了解决方案.
要更新系统中全局安装的angular-cli软件包,您需要运行:
npm uninstall -g angular-cli
npm cache clean or npm cache verify #(if npm > 5)
npm install -g @angular/cli@latest
Run Code Online (Sandbox Code Playgroud)
根据您的系统,您可能需要在上面的命令前加上sudo
.
此外,您很可能还想更新本地项目版本,因为在项目目录中,它的选择优先级高于全局项目:
rm -rf node_modules
npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest
npm install
Run Code Online (Sandbox Code Playgroud)
感谢grizzm0在GitHub上指出这一点.
更新CLI后,您可能也想更新Angular版本.
注意:如果要从旧版本更新到Angular CLI 6+,则可能需要阅读此内容.
编辑:此外,如果您仍然使用cli的1.x版本,则需要转换angular-cli.json
为angular.json
,使用以下命令可以执行此操作:
ng update @angular/cli --from=1.7.4 --migrate-only
Run Code Online (Sandbox Code Playgroud)
(查看此内容以获取更多详情).
Pag*_*dio 146
ng6 + - > 7.0
更新RxJS(取决于RxJS 6.3)
npm install -g rxjs-tslint
rxjs-5-to-6-migrate -p src/tsconfig.app.json
Run Code Online (Sandbox Code Playgroud)
去掉 rxjs-compat
然后更新核心包和Cli:
ng update @angular/cli @angular/core
Run Code Online (Sandbox Code Playgroud)
(可选:将Node.js更新为NG7支持的版本10)
ng6 +(Cli 6.0+):具有简化命令
首先,更新你的Cli
npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli
Run Code Online (Sandbox Code Playgroud)
然后,更新您的核心软件包
ng update @angular/core
Run Code Online (Sandbox Code Playgroud)
如果您使用RxJS,请运行
ng update rxjs
Run Code Online (Sandbox Code Playgroud)
它会将RxJS更新到版本6并rxjs-compat
在引擎盖下安装它.
如果遇到构建错误,请尝试手动安装:
npm i rxjs-compat
npm i @angular-devkit/build-angular
Run Code Online (Sandbox Code Playgroud)
最后,检查您的版本
ng v
Run Code Online (Sandbox Code Playgroud)
生产构建注意事项:
NG6不再使用intl
的polyfills.ts
//remove them to avoid errors
import 'intl';
import 'intl/locale-data/jsonp/en';
Run Code Online (Sandbox Code Playgroud)
ng5 +(Cli 1.5+)
npm install @angular/{animations,common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router}@next typescript@2.4.2 rxjs@'^5.5.2'
npm install typescript@2.4.2 --save-exact
Run Code Online (Sandbox Code Playgroud)
注意:
更新全局和本地程序包后,清除缓存以避免错误:
npm cache verify (recommended)
npm cache clean (for older npm versions)
Run Code Online (Sandbox Code Playgroud)
以下是官方参考:
Kof*_*Yah 89
你可以简单地使用
npm install -g angular-cli
- 如果是你的第一次
npm install -g @angular/cli@latest
- 如果你已经安装,那么更新
小智 32
这个命令工作正常:
npm upgrade -g @angular/cli
Run Code Online (Sandbox Code Playgroud)
Beh*_*lem 32
强大的命令安装并替换最后一个包.
我遇到了类似的问题.我修好了它.
npm install -g @angular/cli@latest
Run Code Online (Sandbox Code Playgroud)
和
npm install --save-dev @angular/cli@latest
Run Code Online (Sandbox Code Playgroud)
Ena*_*yat 17
以下方法对我有用:
npm uninstall -g @angular/cli
Run Code Online (Sandbox Code Playgroud)
然后
npm cache verify
Run Code Online (Sandbox Code Playgroud)
然后
npm install -g @angular/cli@latest
Run Code Online (Sandbox Code Playgroud)
我在Windows 10的工作,有时我不得不使用:npm cache clean --force
为好.如果在安装过程中没有任何问题,则无需执行此操作.
Leo*_*iva 14
我做了他说的但我的包装没有更新角度版本,我知道这篇文章是关于angular-cli
,但我认为这也有帮助.
-ng new projectname
,生成一个包.-npm install
.现在我ng serve
再次工作,也许有更好的方法来做所有这些,如果有人知道,请分享,因为这对所有需要更新的项目都很痛苦.
ARK*_*han 14
就我而言,我已使用 npm install --save-dev angular-cli 在本地安装了 angular-cli。
因此,当我使用 command 时npm install -g @angular/cli
,它会生成错误
您的全局 Angular CLI 版本 (1.7.3) 高于本地版本 (1.4.9)
请注意,Angular-cli、@Angular/cli 和 @Angular/cli@latest 是两个不同的 cli。
解决这个问题的方法是卸载所有 cli,然后使用安装最新的 Angular cli
npm install -g @angular/cli@latest
Run Code Online (Sandbox Code Playgroud)
Kun*_*vič 13
更新:
从CLI v6开始,您可以运行ng update
以便将依赖项自动更新为新版本.
随着
ng update
有时你可能需要添加--force
标志.如果这样做,请确保您当前的角度版本支持以这种方式安装的打字稿版本,否则您可能需要降级打字稿版本.
另请查看本指南更新Angular项目和update.angular.io
您需要做的就是使用angular-cli-diff进行差异并应用当前项目中的更改.
以下是步骤:
--all
选项卡File changed
/npm install
yarn
(更多详情: https ://stackoverflow.com/a/45431592/415078)要将Angular CLI更新为新版本,必须同时更新全局包和项目的本地包.
全球套餐:
npm uninstall -g @angular/cli
npm cache clean
# if npm version is > 5 then use `npm cache verify` to avoid errors (or to avoid using --force)
npm install -g @angular/cli@latest
Run Code Online (Sandbox Code Playgroud)
本地项目包:
rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell
npm install --save-dev @angular/cli@latest
npm install
Run Code Online (Sandbox Code Playgroud)
资料来源:Github
归档时间: |
|
查看次数: |
445056 次 |
最近记录: |