最佳答案
在执行 npm run build 时,我得到了以下错误:
Angular Compiler 需要 TypeScript > = 3.4.0和 < 3.5.0但是3.5.3 却被发现了。
我试着把事情分开来看:
Npm 安装 typeescript@“ > = 3.4.0 < 3.5.0”。然后删除 node _ module 和 package.json。运行 npm install
NPM 更新,警力。 然后删除 node _ module 和 package.json,运行 npm install
我仍然得到错误:
我的 package.json 包含以下依赖项:
"dependencies": {
"@angular/animations": "8.1.0",
"@angular/cdk": "^8.0.2",
"@angular/cli": "^8.1.0",
"@angular/common": "8.1.0",
"@angular/compiler": "8.1.0",
"@angular/core": "8.1.0",
"@angular/forms": "8.1.0",
"@angular/http": "7.2.15",
"@angular/material": "^8.0.2",
"@angular/platform-browser": "8.1.0",
"@angular/platform-browser-dynamic": "8.1.0",
"@angular/router": "8.1.0",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"angular-user-idle": "^2.1.2",
"angular2-cookie": "^1.2.6",
"core-js": "^2.6.7",
"rxjs": "6.5.2",
"rxjs-tslint": "^0.1.5",
"stream": "0.0.2",
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.801.0",
"@angular/compiler-cli": "8.1.0",
"@angular/language-service": "8.1.0",
"@types/jasmine": "~3.3.13",
"@types/jasminewd2": "~2.0.6",
"@types/node": "~12.6.1",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"protractor": "~5.4.2",
"ts-node": "~8.3.0",
"tslint": "~5.18.0",
"typescript": "^3.4.5"
}
Ng-version 的产出如下:
Angular CLI: 8.1.2
Node: 10.16.0
OS: win32 x64
Angular: 8.1.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.801.2
@angular-devkit/build-angular 0.801.2
@angular-devkit/build-optimizer 0.801.2
@angular-devkit/build-webpack 0.801.2
@angular-devkit/core 8.1.2
@angular-devkit/schematics 8.1.2
@angular/cdk 8.1.1
@angular/cli 8.1.2
@angular/http 7.2.15
@angular/material 8.1.1
@ngtools/webpack 8.1.2
@schematics/angular 8.1.2
@schematics/update 0.801.2
rxjs 6.5.2
typescript 3.5.3
webpack 4.35.2
会出什么问题呢?