从Angular 2升级Angular 4后的错误

前端之家收集整理的这篇文章主要介绍了从Angular 2升级Angular 4后的错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
从Angular2升级到Angular4后,我在CLI中遇到这些错误.虽然升级后我的应用程序仍在运行,但我只是想知道如何解决这些错误.有任何想法吗?

升级前的Package.json:

{
  "name": "myapp","version": "0.0.0","license": "MIT","scripts": {
    "ng": "ng","start": "ng serve","build": "ng build","test": "ng test","lint": "ng lint","e2e": "ng e2e"
  },"private": true,"dependencies": {
    "@angular/common": "^2.4.0","@angular/compiler": "^2.4.0","@angular/core": "^2.4.0","@angular/forms": "^2.4.0","@angular/http": "^2.4.0","@angular/platform-browser": "^2.4.0","@angular/platform-browser-dynamic": "^2.4.0","@angular/router": "^3.4.0","core-js": "^2.4.1","foundation-sites": "^6.3.1","ng2-translate": "^5.0.0","rxjs": "^5.1.0","zone.js": "^0.7.6"
  },"devDependencies": {
    "@angular/cli": "1.0.0-rc.1","@angular/compiler-cli": "^2.4.0","@types/jasmine": "2.5.38","@types/node": "~6.0.60","codelyzer": "~2.0.0","jasmine-core": "~2.5.2","jasmine-spec-reporter": "~3.2.0","karma": "~1.4.1","karma-chrome-launcher": "~2.0.0","karma-cli": "~1.0.1","karma-jasmine": "~1.1.0","karma-jasmine-html-reporter": "^0.2.2","karma-coverage-istanbul-reporter": "^0.2.0","protractor": "~5.1.0","ts-node": "~2.0.0","tslint": "~4.4.2","typescript": "~2.0.0"
  }
}

升级后的Package.json:

{
  "name": "myapp","dependencies": {
    "@angular/animations": "^4.0.0","@angular/common": "^4.0.0","@angular/compiler": "^4.0.0","@angular/compiler-cli": "^4.0.0","@angular/core": "^4.0.0","@angular/forms": "^4.0.0","@angular/http": "^4.0.0","@angular/platform-browser": "^4.0.0","@angular/platform-browser-dynamic": "^4.0.0","@angular/platform-server": "^4.0.0","@angular/router": "^4.0.0","typescript": "^2.2.2","typescript": "~2.0.0"
  }
}
升级了@angular库,但没有升级所需的dependecies.我建议你使用npm-check-updates.这是升级package.json中所有依赖项的最简单方法.试试这个:

步骤1.安装npm-check-updates:

npm i -g npm-check-updates

第2步.升级所有依赖项:

npm-check-updates -u

@EDIT:或者是最新版本的npm-check-updates:

ncu -a

步骤3.要安装升级依赖项:

npm install
原文链接:https://www.f2er.com/angularjs/140952.html

猜你在找的Angularjs相关文章