Angular 17:找不到“节点”的类型定义文件

问题描述 投票:0回答:1

我正在尝试将我的

Angular
应用程序从
V16
升级到
V17
。 V17 需要
Typescript 5.2
或更高版本。 当我运行
ng serve
时,出现以下错误:


Error: error TS2688: Cannot find type definition file for 'jquery'.
  The file is in the program because:
    Entry point of type library 'jquery' specified in compilerOptions


Error: error TS2688: Cannot find type definition file for 'node'.
  The file is in the program because:
    Entry point of type library 'node' specified in compilerOptions

尝试了我看到的一切,但暂时没有成功。

我的

tsconfig
文件包括:

{
    "compileOnSave": false,
    "compilerOptions": {
        "baseUrl": "./",
        "resolveJsonModule": true,
        "allowSyntheticDefaultImports": true,
        "paths": {
            "@env": ["src/environments/environment.ts"]
        },
        "outDir": "./dist/out-tsc",
        "forceConsistentCasingInFileNames": true,
        "strict": true,
        "noImplicitReturns": true,
        "noFallthroughCasesInSwitch": true,
        "sourceMap": true,
        "declaration": false,
        "downlevelIteration": true,
        "experimentalDecorators": true,
        "moduleResolution": "node",
        "importHelpers": true,
        "target": "ES2022",
        "module": "es2022",
        "lib": ["es2022", "dom"],
        "types": ["node", "jquery"],
        "typeRoots": ["node_modules/@types"],
        "useDefineForClassFields": false
    },
    "angularCompilerOptions": {
        "enableI18nLegacyMessageIdFormat": false,
        "strictInjectionParameters": true,
        "strictInputAccessModifiers": true,
        "strictTemplates": true,
        "fullTemplateTypeCheck": true
    }
}

我的

package.json

{
  "name": "myApp",
  "version": "5.4.3",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
    "pretty-quick": "pretty-quick --staged",
    "prepare": "husky install"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^17.0.8",
    "@angular/cdk": "^17.0.4",
    "@angular/common": "^17.0.8",
    "@angular/compiler": "^17.0.8",
    "@angular/core": "^17.0.8",
    "@angular/forms": "^17.0.8",
    "@angular/material": "^16.2.0",
    "@angular/platform-browser": "^17.0.8",
    "@angular/platform-browser-dynamic": "^17.0.8",
    "@angular/router": "^17.0.8",
    "@angular/service-worker": "^17.0.8",
    "@mapbox/mapbox-gl-language": "^0.9.2",
    "@ng-idle/core": "^14.0.0",
    "@ngrx/effects": "^15.1.0",
    "@ngrx/store": "^15.1.0",
    "@ngrx/store-devtools": "^15.1.0",
    "@ngu/carousel": "7.0.0",
    "@ngx-translate/core": "^15.0.0",
    "@ngx-translate/http-loader": "^6.0.0",
    "@paypal/paypal-js": "^5.0.3",
    "@sentry/angular-ivy": "^7.54.0",
    "@turf/boolean-point-in-polygon": "^6.5.0",
    "@turf/distance": "^5.1.5",
    "angularx-qrcode": "^14.0.0",
    "chart.js": "^4.4.1",
    "date-fns": "^2.30.0",
    "debug": "^3.1.0",
    "file-saver": "^2.0.2",
    "hammerjs": "^2.0.8",
    "jquery": "^3.5.1",
    "keen-slider": "^6.8.6",
    "lodash.isplainobject": "^4.0.6",
    "mapbox-gl": "^0.53.1",
    "moment": "^2.27.0",
    "ng2-charts": "^5.0.4",
    "ngx-audio-player": "^12.0.2",
    "ngx-cookie-service": "^15.0.0",
    "ngx-image-cropper": "^7.1.2",
    "ngx-infinite-scroll": "^16.0.0",
    "ngx-quicklink": "^0.4.4",
    "ngx-slider-v2": "^17.0.0",
    "quill": "^1.3.3",
    "redux": "4.0.1",
    "redux-devtools-extension": "^2.13.8",
    "redux-logger": "^3.0.6",
    "rxjs": "^7.8.0",
    "shufflejs": "^6.1.0",
    "simplify-ts": "^1.0.1",
    "socket.io": "^2.2.0",
    "tslib": "^2.0.0",
    "video.js": "^7.11.4",
    "webpack-bundle-analyzer": "^4.4.0",
    "zone.js": "~0.14.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^17.0.8",
    "@angular-eslint/builder": "^17.1.1",
    "@angular-eslint/eslint-plugin": "^17.1.1",
    "@angular-eslint/eslint-plugin-template": "^17.1.1",
    "@angular-eslint/schematics": "^17.1.1",
    "@angular-eslint/template-parser": "^17.1.1",
    "@angular/cli": "^17.0.8",
    "@angular/compiler-cli": "^17.0.8",
    "@types/debug": "^4.1.7",
    "@types/file-saver": "^2.0.5",
    "@types/jasmine": "~3.6.0",
    "@types/jquery": "^3.5.5",
    "@types/lodash": "^4.14.182",
    "@types/mapbox-gl": "^0.44.0",
    "@types/moment": "^2.13.0",
    "@types/node": "^20.10.5",
    "@types/socket.io-client": "^1.4.31",
    "@types/video.js": "^7.3.15",
    "@typescript-eslint/eslint-plugin": "^6.10.0",
    "@typescript-eslint/parser": "^6.10.0",
    "cachefactory": "^3.0.0",
    "codelyzer": "^6.0.0",
    "eslint": "^8.53.0",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-jsdoc": "30.7.6",
    "eslint-plugin-prefer-arrow": "1.2.2",
    "husky": "^8.0.2",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.4.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "prettier": "^2.8.1",
    "pretty-quick": "^3.1.3",
    "protractor": "~7.0.0",
    "ts-node": "~10.9.2",
    "typescript": "~5.2.2"
  }
}

谢谢!

angular typescript tsconfig angular17 typescript-5
1个回答
0
投票

我正在使用 monorepo。我认为问题出在 Monorepo 上。没有什么我没有像你一样尝试过。当我打开

tsconfig.ts
文件并删除类型数组时,我发现它工作正常,没有任何问题。我通过构建来测试它。我没有看到开发环境有什么问题。

"types": [
    "node"
],

只需删除我展示的部分并尝试即可。

© www.soinside.com 2019 - 2024. All rights reserved.