每个 vue 组件返回无法读取未定义的属性“parseComponent”

Mar*_*bov 18 npm laravel vue.js

所以我试过研究这个,但没有一个解决方案有效。我认为这可能是我的某些 vue 依赖项的具体问题vue-loader,但我不确定要具体做什么来修复它。我试过了:

  • 删除node_modules并重新运行npm install
  • npm update
  • 我试过vue-loader完全删除
  • 尝试添加、删除和更新 @vue/component-compiler-utils
  • 尝试将上述版本更改为三种不同的内容
  • 尝试运行composer installcomposer update
  • 从 master 创建一个新的临时暂存分支以防万一它是一些奇怪的 git 错误并从中构建

我在这里缺少什么?我的登台站点上的每个 vue 组件都返回相同的错误。最奇怪的是,临时服务器是我们生产服务器的直接克隆,所有这些都可以完全顺利地运行并且我得到零错误。

错误:

ERROR in ./resources/assets/js/components/component.vue
Module build failed (from ./node_modules/vue-loader/lib/index.js):
TypeError: Cannot read property 'parseComponent' of undefined
    at parse (/var/www/site/node_modules/@vue/component-compiler-utils/dist/parse.js:14:23)
    at Object.module.exports (/var/www/site/node_modules/vue-loader/lib/index.js:67:22)
 @ ./resources/assets/js/app.js 60:29-81
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss
Run Code Online (Sandbox Code Playgroud)

我也尝试安装这些警告的依赖项,但仍然出现上述相同的错误,我将这些包含在内是因为这是我运行 bash 脚本并从我的暂存分支运行 npm install 时弹出的内容:

npm WARN eslint-plugin-vue@5.2.3 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN vue-eslint-parser@5.0.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/webpack-dev-server/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
Run Code Online (Sandbox Code Playgroud)

package.json 依赖项

"devDependencies": {
    "axios": "^0.19.0",
    "babel-preset-stage-2": "^6.24.1",
    "browser-sync": "^2.26.7",
    "browser-sync-webpack-plugin": "^2.2.2",
    "cross-env": "^5.2.0",
    "eslint": "^6.1.0",
    "eslint-config-standard": "^13.0.1",
    "eslint-loader": "^2.2.1",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-node": "^9.1.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-standard": "^4.0.0",
    "eslint-plugin-vue": "^5.2.3",
    "exports-loader": "^0.6.4",
    "imports-loader": "^0.7.1",
    "jquery": "^3.3.1",
    "laravel-mix": "^4.1.2",
    "lodash": "^4.17.11",
    "resolve-url-loader": "^3.1.0",
    "sass": "^1.22.10",
    "vue": "^2.6.10"
  },
   "dependencies": {
    "@vue/component-compiler-utils": "^3.1.1",
    "ajv": "^6.10.0",
    "babel-polyfill": "^6.26.0",
    "bootstrap": "^4.3.1",
    "braces": "^2.3.1",
    "es6-promise": "^4.2.6",
    "font-awesome": "^4.7.0",
    "luxon": "^1.12.1",
    "moment": "^2.24.0",
    "popper": "^1.0.1",
    "popper.js": "^1.14.7",
    "sass-loader": "^7.1.0",
    "vue-datetime": "^1.0.0-beta.10",
    "vue-datetime-picker": "^0.2.1",
    "vue-full-calendar": "^2.7.0",
    "vue-loader": "^15.8.3",
    "vue-router": "^3.0.2",
    "vue-template-compiler": "2.6.10",
    "vue-wysiwyg": "^1.7.2",
    "vuex": "^3.1.0",
    "weekstart": "^1.0.0",
    "whatwg-fetch": "^2.0.4",
    "wkhtmltopdf": "^0.3.4"
  }
}

Run Code Online (Sandbox Code Playgroud)

我在想它可能与特定版本的依赖关系有关?但是我从其他堆栈溢出线程或谷歌搜索中尝试过的任何东西都没有帮助

如果缺少任何可能有帮助的代码,请告诉我

say*_*rre 28

我遇到了同样的问题,刚刚想通了,我希望这对某人有所帮助。首先我把vue模板编译器改成:

"vue-template-compiler": "2.6.11"

并且我还必须将 vue 版本更改为最新的 realese,在我的情况下:

"vue": "2.6.11"

  • 可以确认我的问题是旧版本的 vue-loader 和 vue-template-compiler (2认同)

小智 18

尝试这个:

npm remove vue-template-compiler

npm remove vue
Run Code Online (Sandbox Code Playgroud)

然后

npm install vue-template-compiler@2.6.11

npm install vue@2.6.11
Run Code Online (Sandbox Code Playgroud)

这将与您项目上的 vue 和 vue-template 编译器的版本相匹配。


Jes*_*rez 12

尝试运行此命令

npm update vue-template-compiler
Run Code Online (Sandbox Code Playgroud)

  • 不适合我:-( (3认同)

qin*_*127 5

“vue-template-compiler”的版本应该与“vue”的版本相匹配。如果依赖声明为:

"vue": "^2.6.11"
Run Code Online (Sandbox Code Playgroud)

npm 可能会安装 vue@2.6.12,它与“vue-template-compiler”的版本不匹配。至于 2.6.11 和 2.6.12 之间有哪些更新,可以参考发行说明。


小智 5

我遇到了同样的问题,我运行了命令:npm update vue-template-compiler。一切都解决了。