When running "npm run dev" [webpack-cli] Error: Cannot find module 'vue/compiler-sfc' [Laravel with Vue.js]

Viewed 6480
2 Answers

I was having the same problem, basically what was happening is that my version of VUE did not match the version of vue-loader and vue-template-compiler

To solve it I just had to match the versions in package.json and npm install here are the versions I'm using

"vue": "^2.6.11",
"vue-loader": "^15.9.6",
"vue-template-compiler": "^2.6.12",
"laravel-mix": "^6.0.6",

My issue arose after running php artisan ui vue --auth. What happened is that this command added vue v2 as a dev dependency in my package.json, while I had already installed vue 3. Running npm install installed the version 2 vue, which led to a version mismatch with vue-loader and vue-template-compiler.

I solved the issue by getting rid of the added vue 2 dependency, and running npm install again.

Related