independent full stack developer

/ Developer's blog

What if "Cannot find module cross-env" for npm run dev with Laravel 5.5 and Vuejs

Tuesday, September 27, 2022

Hey, I feel anyone can experience such bug with fresh install Ubuntu 16.04 and Laravel 5.5 for your local environment.

So, if you're stumbled with such errors like when you try to use npm run dev

Cannot find module cross-env
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode 
Make sure you have the latest version of node.js and npm installed

Very often it means that you have an old version of your nodejs, so when you install it as apt-get install nodejs, you will install and old LTS version 4.2.6 that too old. To fix it, you just need to update your Nodejs and everything will work seamlessly. How to do it? Follow the next steps.

sudo apt-get install build-essential libssl-dev
curl -sL -o
source ~/.profile
nvm install 8.9.4
nvm use 8.9.4

And viola, when you check the node version (node -v), it will be 8.9.4 and now you can run your npm run dev again and relax.

2254 people already saw it