laravel ‘mix’ is not recognized as an internal or external command

laravel ‘mix’ is not recognized as an internal or external command

When working with Laravel, you may come across an error that says “‘mix’ is not recognized as an internal or external command.” This error occurs when you’re trying to run a mix-related command, such as npm run dev, and Laravel Mix is not properly configured or installed.

In this tutorial, you will learn how to fix or resolve laravel ‘mix’ is not recognized as an internal or external command.

laravel ‘mix’ is not recognized as an internal or external command

Steps to resolve laravel ‘mix’ is not recognized as an internal or external command:

  • Step 1: Verify Node.js and NPM Installation
  • Step 2: Check Environment Path (Windows)
  • Step 3: Navigate to Your Laravel Project Directory
  • Step 4: Install Laravel Mix

Step 1: Verify Node.js and NPM Installation

Open your terminal or cmd and run the following command into it to verify that Node.js and NPM are properly installed on your system:

node -v
npm -v

Step 2: Check Environment Path (Windows)

If you are using Windows and still face the issue, you might need to check your environment variables. The error message you’re encountering indicates that your system can’t find the Mix executable. Here’s how you can fix it:

  1. Open the Windows Start Menu.
  2. Search for “Environment Variables” and select “Edit the system environment variables.”
  3. In the System Properties window, click the “Environment Variables” button.
  4. In the “User variables” section, locate the “Path” variable and click “Edit.”
  5. Ensure that the path to the node_modules/.bin directory within your Laravel project is included. It should look something like this:
    • C:\path\to\your\laravel\project\node_modules.bin
  6. Click “OK” to save your changes.
  7. Close and reopen your terminal or command prompt to apply the changes.
$this->app->bind('path.public', function() {
   return base_path().'/../public_html';
});

Step 3: Navigate to Your Laravel Project Directory

Open your terminal or command prompt and navigate to your Laravel project’s root directory:

cd /path/to/your/laravel/project

Step 4: Install Laravel Mix

Now, run the following command on terminalf or cmd to install the latest version of Laravel Mix.

npm install laravel-mix@latest --save-dev

Conclusion

That’s it! You should now be able to use Laravel Mix for asset compilation without encountering the “‘mix’ is not recognized” error.

Recommended Laravel Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *