【发布时间】:2017-06-22 14:34:09
【问题描述】:
我刚刚将我的 Angular 项目从 2 升级到 4。
我是通过以下方式完成的:
1-删除 /node_modules/ 文件夹
2 次运行:
npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest typescript@latest --save
为了将最新版本添加到 package.json 中
3 次运行 npm 安装
++这里已经有一些奇怪的东西,在树的末端我看到:
4- 运行 ng 构建
我得到的错误信息是:
ERROR in PATH/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts (133,11): All declarations of 'WeakMap' must have identical type parameters.
ERROR in PATH/node_modules/typescript/lib/lib.es2015.iterable.d.ts (124,11): All declarations of 'WeakMap' must have identical type parameters.
ERROR in PATH/node_modules/typescript/lib/lib.es2015.collection.d.ts (45,11): All declarations of 'WeakMap' must have identical type parameters.
ERROR in PATH/node_modules/@types/lodash/index.d.ts (19417,15): All declarations of 'WeakMap' must have identical type parameters.
说“找不到类型对象”
我的 Java 背景告诉我,我使用的编译器对“对象”的解释与库中使用的不同 事实上,我希望“对象”是一个具体的类或接口。 有什么建议吗?
这是我的 package.json
{
"name": "rats-gui",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.2.4",
"@angular/common": "^4.2.4",
"@angular/compiler": "^4.2.4",
"@angular/compiler-cli": "^4.2.4",
"@angular/core": "^4.2.4",
"@angular/forms": "^4.2.4",
"@angular/http": "^4.2.4",
"@angular/material": "^2.0.0-beta.7",
"@angular/platform-browser": "^4.2.4",
"@angular/platform-browser-dynamic": "^4.2.4",
"@angular/platform-server": "^4.2.4",
"@angular/router": "^4.2.4",
"@types/lodash": "ts2.0",
"angular2-datatable": "0.5.3",
"core-js": "^2.4.1",
"hammerjs": "^2.0.8",
"lodash": "^4.17.4",
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"typescript": "^2.3.4",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/compiler-cli": "^4.2.4",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.28.3",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"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.13",
"ts-node": "1.2.1",
"tslint": "^4.3.0",
"typescript": "2.1.5"
}
}
【问题讨论】:
-
您是否尝试关闭 IDE 并运行 - npm clean cache - npm install
-
试过:'npm cache clean' > 'npm install' > 'ng build' 仍然失败
-
对不起,我想说 npm cache clear #清理 npm 缓存
-
你能给我看看你的 package.json 吗?
-
我明白了,谢谢@ZinebErrahmouni,但不幸的是问题仍然存在
标签: angular typescript