(编辑问题) 升级包和依赖项后,
"typescript": "2.1.1"
"typings": "^0.8.1"
"zone.js": "^0.8.4"
"rxjs": "5.0.1"
使用 upgrade 命令将 angular 包升级到 4.0.0 没有帮助。我正在按照相同的顺序做通常的npm run clean
、npm install
和npm run build
。我应该更改键入的版本吗?
ERROR in [default] node_modules/@angular/core/src/change_detection/differs/iterable_differs.d.ts:15:47
Cannot find name 'Iterable'.
ERROR in [default] /typings/browser/ambient/node/index.d.ts:426:10
Interface 'NodeBuffer' incorrectly extends interface 'Uint8Array'.
Types of property 'fill' are incompatible.
Type '(value: any, offset?: number, end?: number) => Buffer' is not assignable to type '(value: number, start?: number, end?: number) => this'.
Type 'Buffer' is not assignable to type 'this'.
按如下方式更新您的软件包:
"dependencies": {
"@angular/animations": "^4.0.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^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/router": "^4.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@types/node": "~6.0.60",
"ts-node": "~2.0.0",
"typescript": "~2.2.0"
}
将以下内容添加到 tsconfig.json, in compipleroptions
"compilerOptions": {
"skipLibCheck": true
}
我尝试了很多其他用户的建议。以下是我最终解决/消除错误的方式:
- 从 2.0.0 一直到 2.4.10 的增量升级开始,仅更改 angular 的版本 接下来从2.4.0
- 升级到4.0.0-beta.6开始,在那里我遇到了第一个错误:
ERROR in [default] node_modules/@angular/core/src/change_detection/differs/iterable_differs.d.ts:15:47 Cannot find name 'Iterable'.
为了解决这个问题,我通过typings install dt~core-js --global --save
安装了typings.core-js,然后继续在main.ts
的顶部添加/// <reference path="../typings/index.d.ts" />
。这消除了Iterable
的问题
- 在
升级到 4.0.0 结束时,我尝试将 Typescript 升级到
^2.1.5
,但它给出了很多错误,所以我降级到2.0.3
(在其中一个角度问题中阅读),这有助于我成功运行npm install
和npm run build
。由于我还在使用
typings/ambient
,我遇到了这篇关于升级到 typings 1.x 的文章。我用正确的版本重新安装了打字,终于能够成功构建但我在控制台中看到
routes
错误,因为我之前没有在我的路线中提到pathMatch: 'full'
。一旦我包含pathMatch
字段,我就可以让应用程序正常运行。