Laravel 5.4 ‘cross-env’ Is Not Recognized as an Internal or External Command
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
Title: Understanding 'cross-env' Not Recognized Error in Laravel Mix
Body:
Laravel is an impressive PHP framework that allows developers to build powerful web applications in a simple and elegant manner. One of the tools used for asset management within this framework is Laravel Mix, which uses npm run dev to execute a development task. But sometimes, the process can be interrupted by an error message: "cross-env" is not recognized as an internal or external command.
Troubleshooting 'cross-env' Not Recognized Error
Ensure your environment supports Node.js: First, check if your operating system and version support Node.js. Make sure you have the right version of Node.js installed on your computer. If it is not already installed, download and install it from Node.js official website.
Run a clean npm cache: Clear the npm cache by running these commands in the command prompt or terminal window:
npm cache clear --forcenpm cache verify
- Update node_modules folder contents: Clear the node_modules folder and run a clean install of required dependencies by running these commands inside your Laravel project directory:
rm -rf node_modules && npm cache clear --forcenpm install
- Install cross-env globally: Since the error message is about cross-env not being recognized, you might need to install it separately. To do so, run this command in your terminal window:
npm install -g cross-env --save-dev- Update Laravel Mix version: Sometimes, an incorrect combination of Node and npm versions can cause the issue. Check the current Laravel Mix version by running
node_modules/.bin/laravel-mix ls. If it's not the latest one, update Laravel Mix using:
npm install -S laravel-mix@latest- Update dependencies: Ensure that all of your project's dependencies are up-to-date by running a clean npm cache and updating dependencies:
npm update --forcenpm install
- Check your environment variables: Sometimes, the problem can be related to environment variables. Ensure that they are set up correctly in Windows by setting "PATH" or adding node_modules folder paths to it, and adding Node to your PATH. For more information on environment variables, refer to this blog post.