You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Nuxt 2 重装node_modules启动时出现TypeScript 'length未定义'错误

Nuxt v2 重装node_modules后执行npm run dev报TypeError: Cannot read property 'length' of undefined

我用Nuxt v2开发项目,此前运行完全正常。但在删除并重装node_modules后,执行npm run dev时出现了TypeScript相关错误:

TypeError: Cannot read property 'length' of undefined

当前环境版本:

  • Node.js: v14.21.3
  • NPM: v6.14.18

我的package.json依赖配置如下:

"dependencies": {
    "@fortawesome/fontawesome-free": "^5.15.2",
    "@nuxt/typescript-runtime": "^1.0.0",
    "@nuxtjs/axios": "^5.12.5",
    "@nuxtjs/moment": "^1.6.1",
    "@nuxtjs/sitemap": "^2.4.0",
    "@popperjs/core": "^2.6.0",
    "body-parser": "^1.19.0",
    "bootstrap": "^4.6.0",
    "bootstrap-vue": "^2.21.2",
    "core-js": "^3.9.1",
    "core-util-is": "^1.0.2",
    "country-list": "^2.2.0",
    "dateformat": "^3.0.3",
    "jquery": "^1.12.4",
    "kentico-kontent-nuxt-module": "^6.1.0",
    "libphonenumber-js": "^1.9.6",
    "moment-timezone": "^0.5.32",
    "nuxt": "^2.15.3",
    "nuxt-i18n": "^6.27.0",
    "nuxt-vuex-localstorage": "^1.2.7",
    "portal-vue": "^2.1.7",
    "rxjs": "^6.6.3",
    "twitter-widgets": "^2.0.0",
    "universal-cookie": "^4.0.4",
    "validator": "^13.1.17",
    "vue-masonry-css": "^1.0.3",
    "vue-recaptcha-v3": "^1.9.0",
    "vue-scrollto": "^2.19.1",
    "vue2-google-maps": "^0.10.7",
    "vuex-persistedstate": "^3.2.0"
  },
  "devDependencies": {
    "@nuxt/types": "^2.14.12",
    "@nuxt/typescript-build": "^2.0.4",
    "@nuxtjs/dotenv": "^1.4.1",
    "@nuxtjs/style-resources": "^1.0.0",
    "eslint": "^4.19.1",
    "node-sass": "^4.14.1",
    "pug": "^3.0.0",
    "pug-plain-loader": "^1.1.0",
    "sass-loader": "^10.1.1"
  }

我已经尝试将Node.js升级到v14的最新版本,但问题依然存在,请问该如何解决?

内容的提问来源于stack exchange,提问作者ChanhHuynh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 18:23:22