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

2

8

after I installed vue.js on my laravel project and running npm run dev this error comes out.

enter image description here

Vittle answered 3/2, 2022 at 10:39 Comment(2)
just do an npm install @vue/compiler-sfc. More info here: npmjs.com/package/@vue/compiler-sfcAscospore
@doesnotmatter Not if your vue version is 3Noncompliance
C
18

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",
Chouest answered 10/2, 2022 at 8:44 Comment(3)
This work with me in laravel 8 the problem was from vue-loader version it was version 17.0.0 i changed it to 15.9.6 thanks Boutghat.Cardiomegaly
This worked for me as well. I think this issue occurs basically on MacBook. When using Windows PC, everything works fine with "vue-loader": "^17.0.0".Medellin
I don't think it has anything to do with the OS !! the issue occurred to me in both windows and linuxChouest
W
2

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.

Weasel answered 29/3, 2022 at 10:18 Comment(1)
Need to get rid of both of these: ` "vue": "^2.6.12", "vue-template-compiler": "^2.6.12" `Noncompliance

© 2022 - 2024 — McMap. All rights reserved.