从7升级到8 [英] Upgrade angular from 7 to 8

查看:104
本文介绍了从7升级到8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个新项目,启动堆栈正在使用角度版本7,我想升级到版本8.因此,我使用了以下命令ng update @angular/cli @angular/core. 运行上面的命令后,我的package.json文件没有更改:

I'm working on a new project, the startup stack is using angular version 7, I want to upgrade to the version 8. so I used the following command ng update @angular/cli @angular/core. After running the above command, my package.json file didn't change:

"dependencies": {
    "@angular/animations": "^7.0.2",
    "@angular/common": "^7.0.2",
    "@angular/compiler": "^7.0.2",
    "@angular/core": "^7.0.2",
    "@angular/forms": "^7.0.2",
    "@angular/http": "^7.0.2",
    "@angular/platform-browser": "^7.0.2",
    "@angular/platform-browser-dynamic": "^7.0.2",
    "@angular/router": "^7.0.2",
    "@angular/service-worker": "^7.0.2",
    "@fortawesome/fontawesome-free-webfonts": "^1.0.9",
    "@ng-bootstrap/ng-bootstrap": "4.0.0",
    "@ng-select/ng-select": "^2.12.0",
    "@ngx-translate/core": "11.0.0",
    "@pioneer-code/pioneer-tree": "^2.1.0",
    "@types/async": "^2.0.50",
    "async": "^2.6.1",
    "bootstrap": "^4.1.1",
    "core-js": "^2.5.6",
    "lodash": "^4.17.11",
    "ngx-bootstrap": "^3.1.1",
    "ngx-toggle-switch": "^2.0.5",
    "node-sass": "^4.10.0",
    "rxjs": "^6.3.3",
    "rxjs-compat": "^6.3.3",
    "underscore": "^1.9.1",
    "zone.js": "^0.8.26"
  },

推荐答案

您还可以使用以下步骤升级到9角

注意:

您应该深入导入,而不是从@angular/material导入 从特定的组件.例如. @angular/material/button. ng update 会自动为您完成此操作.

Instead of importing from @angular/material, you should import deeply from the specific component. E.g. @angular/material/button. ng update will do this automatically for you.

1-升级您的 Node.js

2-升级Angular CLI :(先卸载以前的版本,然后再安装新版本)

2-Upgrade your Angular CLI:(uninstall the previous version then install new version)

npm uninstall -g @angular/cli
npm cache verify
# if npm version is < 5 then use `npm cache clean`
npm install -g @angular/cli@latest

3-升级您的TypeScript :(最好是全局升级所有依赖项)

3-Upgrade your TypeScript: (It's better to upgrade global all dependencies)

npm update -g

4-升级项目的所有主要依赖项:

4-Upgrade all the main dependencies of the project :

ng update @angular/cli
ng update @angular/core
ng update rxjs

如果您使用的是角材料

ng update @angular/material

5-升级项目的第三方依赖项:

5-Upgrade the third party dependencies of the project:

npm install npm-check-updates -g
ncu -u
npm install

第二个命令(ncu -u)更改package.json中软件包的版本号

这篇关于从7升级到8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆