在更新 Angular 8 到 9 时在 ../node_modules/@types/jquery/index.d.ts:8143:87 中构建错误
build ERROR in ../node_modules/@types/jquery/index.d.ts:8143:87 when updating Angular 8 to 9
我已将应用程序从 angular 8 版本升级到 9 版本。当我进行构建时出现以下构建错误
构建命令:ng build --base-href /test/ --watch, ng build --base-href /test/ --prod
Package.json
{
"name": "test",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^9.1.0",
"@angular/common": "^9.1.0",
"@angular/compiler": "^9.1.0",
"@angular/core": "^9.1.0",
"@angular/forms": "^9.1.0",
"@angular/http": "^7.2.15",
"@angular/localize": "^9.1.0",
"@angular/platform-browser": "^9.1.0",
"@angular/platform-browser-dynamic": "^9.1.0",
"@angular/router": "^9.1.0",
"@ng-bootstrap/ng-bootstrap": "^4.2.2",
"@types/html2canvas": "0.0.33",
"core-js": "^2.5.4",
"html2canvas": "^1.0.0-alpha.12",
"rxjs": "^6.5.5",
"zone.js": "~0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.12",
"@angular/cli": "^9.1.0",
"@angular/compiler-cli": "^9.1.0",
"@angular/language-service": "^9.1.0",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "^5.0.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^6.0.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "~3.8.3"
}
}
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"downlevelIteration": true,
"module": "esnext",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
angular cli 版本:9.1.0,节点 js 版本:12.16.1,
我无法构建应用程序,我也尝试删除 node_modules 文件夹并执行 npm install 但出现相同的错误。不知道我错过了什么,任何人都可以帮忙
- 您是否尝试过在 tsconfig 的 compilerOptions 中将 "skipLibCheck" 设置为 true?
- 尝试将您的打字稿包降级到版本 3.5.3
Typescript 模块@type/jquery 抛出错误,因为 jquery 不能很好地与当前的 typescript 版本兼容。我们可以降级 typescript 的版本,或者如果我们计划使用最新版本的 typescript 安装最新版本的@type/jquery 将解决问题。
这两个简单的步骤对我有用。
rm -rf ./node_modules/@types/jquery
npm install @type/jquery3.5.5 // ( at this time typescript Version 4.1.3 you can opt for latest version @type/jquery3.5.5)
我已将应用程序从 angular 8 版本升级到 9 版本。当我进行构建时出现以下构建错误
构建命令:ng build --base-href /test/ --watch, ng build --base-href /test/ --prod
Package.json
{
"name": "test",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^9.1.0",
"@angular/common": "^9.1.0",
"@angular/compiler": "^9.1.0",
"@angular/core": "^9.1.0",
"@angular/forms": "^9.1.0",
"@angular/http": "^7.2.15",
"@angular/localize": "^9.1.0",
"@angular/platform-browser": "^9.1.0",
"@angular/platform-browser-dynamic": "^9.1.0",
"@angular/router": "^9.1.0",
"@ng-bootstrap/ng-bootstrap": "^4.2.2",
"@types/html2canvas": "0.0.33",
"core-js": "^2.5.4",
"html2canvas": "^1.0.0-alpha.12",
"rxjs": "^6.5.5",
"zone.js": "~0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.12",
"@angular/cli": "^9.1.0",
"@angular/compiler-cli": "^9.1.0",
"@angular/language-service": "^9.1.0",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "^5.0.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^6.0.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "~3.8.3"
}
}
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"downlevelIteration": true,
"module": "esnext",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
angular cli 版本:9.1.0,节点 js 版本:12.16.1,
我无法构建应用程序,我也尝试删除 node_modules 文件夹并执行 npm install 但出现相同的错误。不知道我错过了什么,任何人都可以帮忙
- 您是否尝试过在 tsconfig 的 compilerOptions 中将 "skipLibCheck" 设置为 true?
- 尝试将您的打字稿包降级到版本 3.5.3
Typescript 模块@type/jquery 抛出错误,因为 jquery 不能很好地与当前的 typescript 版本兼容。我们可以降级 typescript 的版本,或者如果我们计划使用最新版本的 typescript 安装最新版本的@type/jquery 将解决问题。
这两个简单的步骤对我有用。
rm -rf ./node_modules/@types/jquery
npm install @type/jquery3.5.5 // ( at this time typescript Version 4.1.3 you can opt for latest version @type/jquery3.5.5)