goatshark's avatar

Vue error every time app.scss is compiled

Greetings. I've had a strange problem with a handful of recent projects (all L5.4). I will have to check on the exact versions, but it's been every new Laravel project in the last month or so.

Typical setup, using Vue, watching/compiling it with an unaltered webpack.mix.js file (npm run watch). Everything works well.

Any time I update app.scss or _variables.scss (seemingly anything having to do with css), it gets compiled successfully, but any page loads result in a console error...

Uncaught TypeError: Cannot read property 'common' of undefined

If I save a couple of my .vue files, compilation is executed again and everything works as expected. Seriously, I just open a couple component files and save them. I found that just saving one file once didn't do the trick.

It's as if compiling layout changes (css), while not making nmp run watch cranky, is making the compile app.js cranky. The fix, every time, just save a few Vue components and let things get compiled again.

Thoughts? Has anyone else seen this?

0 likes
19 replies
goatshark's avatar

@jminklerdmopc I don't have any more data about this failure than I did when I posted it. It isn't that my troubleshooting hasn't gone anywhere. It is that I'm not yet sure where to start troubleshooting. I think I'll jump back into it tomorrow and see if I can come up with anything. I will, of course, post any results.

goatshark's avatar

@jminklerdmopc Just an update to the thread. Out of the box Laravel 5.5 project . . . seeing the same thing. If I make changes to my css, I see this error until I re-save a Vue file at least 3 times. I know it sounds like bad troubleshooting data, but it's all I have so far.

andreasbakir's avatar

i would suggest to remove your node_modules folder and reinstall all node packages with yarn or npm

rm -rf node_modules/
yarn // or npm install
goatshark's avatar

@andreasbakir That's an interesting point. I've been continuing to use npm install and haven't touched yarn yet. I'll try whacking the node_modules and reinstalling packages. Thanks for the suggestion.

andreasbakir's avatar

@goatshark I had a similar problem and reinstalling everything from scratch with yarn fixed it for me :) You are welcome, let us know if it fixed your problem :)

goatshark's avatar

@andreasbakir Good call on the removing node_modules and re-installing. That worked.

This was the first time I've installed with yarn instead of npm install. At this point, I won't know if it was rebuilding the node_modules directory alone that fixed it or if it was the use of yarn during the rebuild that fixed it. It was enough of a PITA though that I'm pretty okay with that this time.

Thanks again.

andreasbakir's avatar

Glad it worked out! yarn is so much faster than npm so it is a win/win situation haha

goatshark's avatar

@andreasbakir I almost feel bad posting this... Looks like whatever the issue is, it's still there. After the first couple of saves, the same symptoms started again. I am going to dig into this over the weekend. I will, of course, post anything interesting (or fixing) I find.

goatshark's avatar

@andreasbakir Will do! Today I have new strategy. I call it "harsh language and threats". I am optimistic. Your milage may vary.

goatshark's avatar

Hey @edoc, no update yet. Thanks for the link to that github issue. I did jump into that thread and will stick around in there to see where it goes. If/when something good is found, I'll get back in here and post about it.

edoc's avatar

Thanks!! I will do the same

goatshark's avatar

@edoc Here's a strange find. I've done half a dozen or so Laravel 5.5 projects that all have this problem. I have never used yarn before yesterday. For whatever reason, I used yarn add instead of npm install to install something random, in this case, 'autosize'.

After installing something via yarn, this project does not have this issue. I'm going to yarn install something in one of the other projects to see if it (magically) fixes it.

I know this isn't great troubleshooting data, but I just realized it so I haven't had time to dig in yet.

goatshark's avatar

@edoc Cancel that. It appears to still have the same issue. My testing procedure needs modified. :)

edoc's avatar

Thanks for the heads-up. What I have done so far

  • update Yarn to 1.1
  • update Node to 8.6
  • update Laravel mix to 1.4.2
  • delete the node-modules folder and run yarn

But none of them worked, and I still get Undefined property error after modifying .scss files sigh...

I will continue debugging the issue.

Good luck @goatshark

goatshark's avatar

@edoc This problem appears to be fixed. I upgraded laravel-mix and after doing that, things seem good.

npm update didn't do it for me, so I checked my package.json file. It had this for laravel-mix:

"laravel-mix": "^1.0",

I changed that line to this:

"laravel-mix": "^1.4.5",

..and then ran npm update. The symptoms have now disappeared. Yay. I'm still a little skeptical, so I'm going to re-test this in a few other projects. That said, I think this might be a fix (although still a mystery).

1 like
edoc's avatar

@goatshark Yea I was actually about to tell you the same. The bug seems to be fixed after updating Laravel Mix.

Thanks for letting me know! Have a good one

Please or to participate in this conversation.