由于错误,无法为 Vue3 项目执行 `npm run build`

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

我已经在 Vue3 中构建了一个项目,现在我正在尝试

npm run build
该项目(节点版本 20.17.0)。我收到以下错误(在node_modules/@types/node/stream/web.d.ts:469:56 - '?'预期):

错误编译失败,有 1 个错误 12:02:09 PM

node_modules/@types/node/stream/web.d.ts:469:56 中出现错误

TS1005:“?”预期的。 467 | 467 // 如果去掉ReportingObserver检查,这里的类型会在TS5.0+lib.dom.d.ts中形成循环引用 468 | 468 报告观察员:任意;

469 | DecompressionStream:推断T扩展对象; | ^ 470 | 470 } ?时间 471 | 471 // TS 4.8、4.9、5.0 472 | 472 : typeof globalThis 扩展 { onmessage: any; TransformStream: { 原型: 推断 T } } ? {

ERROR 错误:构建失败并出现错误。 错误:构建失败并出现错误。

请指教。

npm run serve
运行得很好。这里是
package.json
文件:

{
  "name": "[hidden]",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "@aws-amplify/ui-vue": "^4.2.8",
    "@popperjs/core": "^2.11.8",
    "@vuepic/vue-datepicker": "^8.8.0",
    "@vueuse/core": "^10.11.0",
    "aws-amplify": "^6.3.6",
    "axios": "^1.7.2",
    "bootstrap": "^5.3.3",
    "chart.js": "^4.4.4",
    "core-js": "^3.8.3",
    "lodash": "^4.17.15",
    "pinia": "^2.1.7",
    "sortablejs": "^1.15.2",
    "vue": "^3.2.13",
    "vue-chartjs": "^5.3.1",
    "vue-class-component": "^8.0.0-0",
    "vue-i18n": "^9.13.1",
    "vue-router": "^4.0.3",
    "vue-select": "^4.0.0-beta.6",
    "vue-toastification": "^2.0.0-rc.5",
    "vuedraggable": "^4.1.0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.4.0",
    "@typescript-eslint/parser": "^5.4.0",
    "@vue/cli-plugin-babel": "~5.0.0",
    "@vue/cli-plugin-eslint": "~5.0.0",
    "@vue/cli-plugin-router": "~5.0.0",
    "@vue/cli-plugin-typescript": "~5.0.0",
    "@vue/cli-service": "~5.0.0",
    "@vue/eslint-config-typescript": "^9.1.0",
    "eslint": "^7.32.0",
    "eslint-plugin-vue": "^8.0.3",
    "sass": "^1.32.7",
    "sass-loader": "^12.0.0",
    "typescript": "~4.5.5"
  }
}

这是一个在 localhost:8080 上运行的简单管理面板

node.js vuejs3
1个回答
0
投票

迁移到Vite和Node v22后,OP解决了这个问题。

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