Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Every vue component returning Cannot read property 'parseComponent' of undefined

So i've tried researching this but none of the solutions are working. I think it's specifically an issue with some of my vue dependencies, potentially vue-loader, but I'm not sure what specifically to do to fix it. I have tried:

  • deleting node_modules and re-running npm install
  • npm update
  • i've tried removing vue-loader completely
  • tried adding, removing, and updating @vue/component-compiler-utils
  • tried changing the version of the above to three different things
  • tried running composer install and composer update
  • creating a new temp staging branch from master just in case it was some weird git error and building from that

What am I missing here? Every vue component on my staging site returns this same error. The weirdest thing is that the staging server is a direct clone of our production server, where all of this works completely smoothly and i get zero errors.

The Errors:

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

I've tried installing these warnings' dependencies as well but still get the same error above, I'm including these because it's what pops up when i run my bash script and run npm install from my staging branch:

npm WARN [email protected] requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/webpack-dev-server/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

package.json dependencies

"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"
  }
}

I'm thinking it might have something to do with a specific version of a dependency? But nothing i've been trying from other stack overflow threads or google searches has been helping

Let me know if there's any code missing that may help

like image 644
movac Avatar asked Jan 22 '20 20:01

movac


4 Answers

I had exacly the same problem and just figured it out, I hope this helps someone. First I changed the vue template compiler to:

"vue-template-compiler": "2.6.11"

and the I also had to change the vue version to the latest realese, in my case:

"vue": "2.6.11"

like image 176
sayil aguirre Avatar answered Oct 16 '22 20:10

sayil aguirre


Try running this command

npm update vue-template-compiler
like image 39
Jesus Erwin Suarez Avatar answered Oct 16 '22 19:10

Jesus Erwin Suarez


Try this:

npm remove vue-template-compiler

npm remove vue

then

npm install [email protected]

npm install [email protected]

This will match the version of vue and vue-template compiler on your project.

like image 15
Mon Butiong Avatar answered Oct 16 '22 18:10

Mon Butiong


The version of "vue-template-compiler" should match the version of "vue". If the dependency is declared as:

"vue": "^2.6.11"

Npm will possibly install [email protected], which is mismatched with the version of "vue-template-compiler". As of what updates between 2.6.11 and 2.6.12, you can refer to the release notes.

like image 10
magentaqin Avatar answered Oct 16 '22 19:10

magentaqin