我试图升级我的角度2项目从 2.0.0
到 2.4.1
。我知道自从 2.0.0
发行版以来,语义版本控制已经被采用,而 2.x.x
发行版应该是插入式的替代品。我的经验似乎表明并非如此。也许我只是不知道我在做什么,但我没有发现这是直截了当的..。
我天真的第一个方法是手动更新我的 @angular
依赖项。您可以在下面引用我的 package.json (更新1)。我做了这些修改,然后做了一个 npm install
和我得到了几个警告,然后得到了下面的错误,当我试图做一个 ng serve
。
无法读取未定义的属性“ AssetUrl”
我的警告。
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.15: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN @angular/core@2.4.1 requires a peer of rxjs@^5.0.1 but none was installed.
npm WARN @angular/core@2.4.1 requires a peer of zone.js@^0.7.2 but none was installed.
npm WARN @angular/http@2.4.1 requires a peer of rxjs@^5.0.1 but none was installed.
npm WARN @angular/compiler-cli@0.6.4 requires a peer of @angular/compiler@2.0.2 but none was installed.
npm WARN @angular/compiler-cli@0.6.4 requires a peer of @angular/platform-server@2.0.2 but none was installed.
npm WARN @angular/compiler-cli@0.6.4 requires a peer of @angular/core@2.0.2 but none was installed.
npm WARN @ngtools/webpack@1.2.1 requires a peer of @angular/compiler-cli@^2.3.1 but none was installed.
npm WARN @ngtools/webpack@1.2.1 requires a peer of @angular/tsc-wrapped@^0.5.0 but none was installed.
npm WARN @ngtools/webpack@1.2.1 requires a peer of webpack@^2.1.0-beta.25 but none was installed.
因此,我陷入了试图修复这些警告的兔子洞,但我不知道如何修复所有这些警告(例如@ngtools/webpack) ,其中一些警告似乎相互冲突。所以我放弃了手动更新我的角度2版本..。
原始包裹 json
{
"name": "frontend",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"build": "ng build",
"buildProd": "ng build --env=prod"
},
"private": true,
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/material": "^2.0.0-alpha.9-experimental-pizza",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@types/google-libphonenumber": "^7.4.8",
"angular2-datatable": "^0.4.2",
"apollo-client": "^0.4.22",
"core-js": "^2.4.1",
"google-libphonenumber": "^2.0.4",
"graphql-tag": "^0.1.15",
"hammerjs": "^2.0.8",
"ng2-bootstrap": "^1.1.16",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.2",
"zone.js": "^0.6.26"
},
"devDependencies": {
"@types/hammerjs": "^2.0.33",
"@types/jasmine": "^2.2.30",
"@types/lodash": "^4.14.39",
"angular-cli": "1.0.0-beta.16",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.9",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.2",
"typings": "1.4.0"
}
}
更新 package.json 的1
{
"name": "frontend",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"build": "ng build",
"buildProd": "ng build --env=prod"
},
"private": true,
"dependencies": {
"@angular/common": "2.4.1",
"@angular/compiler": "2.4.1",
"@angular/core": "2.4.1",
"@angular/forms": "2.4.1",
"@angular/http": "2.4.1",
"@angular/material": "^2.0.0-alpha.9-experimental-pizza",
"@angular/platform-browser": "2.4.1",
"@angular/platform-browser-dynamic": "2.4.1",
"@angular/router": "3.0.0",
"@types/google-libphonenumber": "^7.4.8",
"angular2-datatable": "^0.4.2",
"apollo-client": "^0.4.22",
"core-js": "^2.4.1",
"google-libphonenumber": "^2.0.4",
"graphql-tag": "^0.1.15",
"hammerjs": "^2.0.8",
"ng2-bootstrap": "^1.1.16",
"rxjs": "5.0.1",
"ts-helpers": "^1.1.2",
"zone.js": "^0.7.2"
},
"devDependencies": {
"@types/hammerjs": "^2.0.33",
"@types/jasmine": "^2.2.30",
"@types/lodash": "^4.14.39",
"angular-cli": "1.0.0-beta.16",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.9",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.2",
"typings": "1.4.0"
}
}
因为当我试图挑选我的角度依赖更新,我结束了一个蜘蛛网的其他依赖需要更新,我接下来试图只是更新一切。
基于 这个答案,我尝试了以下方法:
npm i -g npm-check-updates
npm-check-updates -u
npm install
这很好,但是当我尝试发球时,我得到了下面的错误:
AppModule 中的 ERROR 不是 NgModule
利用收集到的 给你信息,我降低了打印版本的等级,这个错误消失了,但是出现了一个新的错误。
遇到静态解析符号值的错误。 对非导出函数的引用(原文中的位置29:10) . ts 文件) ,解析符号 restPath 中的 rest-path. ts,解析符号 中的 AppModule, 在 app.module.ts 中解析符号 AppModule
我一直在努力克服这些错误,但是我遇到这么多麻烦的事实却引起了人们的警觉。
有人能帮忙吗,我是不是走错路了?
注意,我已经看到了一些关于更新 angle-cli 项目的建议,这些建议建议卸载 angle-cli 并重新安装它,然后执行 ng init 并覆盖您的配置文件。这对我不起作用,因为我已经有了最新的版本。
编辑:
有关最新角斜率的说法是不正确的。我有 angular-cli version 1.0.0-beta.16
,而最新的在这个编辑时间是 1.0.0-beta.24
。尽管如此,我还是尝试更新我的角度斜面,并在我现有的项目上运行 init。我现在注意到,我没有遵循的步骤概述了棱角-cli github 页面精确。我跳过了 npm install --save-dev angular-cli@latest
,并且删除了所有 node _ module,而没有使用它们概述的 rm 命令。