Laravel Mix : Troubleshoot NPM Run Dev Problem

Recently, Laravel has released its v5.4 which comes with a lot of brand new features. One of them is Laravel Mix. It’s totally brand new cool technology which claimed perform better than old Laravel Elixir Gulp. You can dig more if you interested about what is Laravel Mix by reading their documentation right here.

I’m not going to write about Laravel Mix theory (you can find a lot of article on the net). So, this is about my experience using this brand new Laravel Mix: how I getting started with, and problems that I found.

Getting Started

So I initialize my project and installing Laravel 5.4 (just as usual). I’am using Laravel Homestead (last year version, well sorry don’t reckon what version) and I do usual homestead settings to get my project running on my local machine.

Laravel Mix

Then, I try to following Laravel documentation here. I’am not adding any piece of code inside my project. Still on its original state.

First, I install NPM on my directory project. I run this on my terminal.

npm install

Everything works fine. No errors found so far. Great! now the next step, i run mixing process by run this following code.

npm run dev

… and yes. The bad news showing up. There are errors that you don’t expect to see (Hey, this is the fresh install of Laravel and I getting those bunch of errors?)

I’am getting this following errors

Node JS version

Couple hours spent to figure out what is going on here, and found nothing. Some people said that it could be the Node Version u’re using to run was not the latest version. I think, i will give it try, since (as picture shown above) my node version was the old version. So initiate update to my node js to v7.5.0.

How I done node update: first, I removed my previous node installation (a little help if you are using mac and don’t know what to do), and get install the latest node version.

Done? not yet. Instead of getting my assets mixed, I was getting a brand new errors message.

Brand new kind of errors

Rebuild your Node

I try another search on google and some discussion with my senior, and finally found the answer. This link help me to get out from mixing problem. I try to rebuild my Npm Node and running this following command inside my terminal (make sure that you’ve pointed your project directory before rebuild your Node)

npm rebuild node-sass

Voila! After rebuild my Node, I try to run Laravel Mix again and now it’s working a like a magic!

Congratulation! You’re good to go now


Please leave your feedback below to help me create a better writing on the next post. And also, don’t hesitate to share your experience using Laravel mix, your problems, solutions, etc (maybe it will help someone else lives. who knows).

I hope this article might be useful for you. Thank you for reading this article

Like what you read? Give Budi Purnomo a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.