question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sh: 1: mix: not found

See original GitHub issue

Mix: Tried multiple 6,0 versions. Node: 12.19.0 NPM: 7.6.3 OS: Windows 10

Once again I am having issues with a new version of Laravel Mix.

npm run watch-poll throws a “sh: 1: mix: not found” error.

Fresh Laravel 8.12 installation. Don’t have any colons in the folder name, Have tried deleting node_modules, clearing cache and reinstalling via both NPM and Yarn. Have tried updating Laravel Mix to the latest versions.

I’m using --no-bin-links because npm install never works without it.

Laravel 7 and Mix 5 work perfectly fine, in fact after Laravel 8 failed I tried a fresh Laravel 7 installation and had no issues.

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "mix",
        "watch": "mix watch",
        "watch-poll": "mix watch -- --watch-options-poll=1000",
        "hot": "mix watch --hot",
        "prod": "npm run production",
        "production": "mix --production"
    },
    "devDependencies": {
        "axios": "^0.21",
        "laravel-mix": "^6.0.6",
        "lodash": "^4.17.19",
        "postcss": "^8.1.14"
    },
    "dependencies": {
        "bootstrap": "^5.0.0-beta2"
    }
}
const mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel applications. By default, we are compiling the CSS
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/bootstrap.scss', 'public/css')
    .sass('resources/sass/app.scss', 'public/css')
    .version();

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
green255commented, May 17, 2021

This has to do with the no bin links on windows and the syntax of the new package.json file. I solved this by doing the following:

  1. open up powershell as admin
  2. navigate to project root
  3. run this command
node c:\<path to node installation>\node_modules\npm\bin\npm-cli.js install --scripts-prepend-node-path=auto

Full answer here: https://stackoverflow.com/a/67574817/1272667

2reactions
lmeyselcommented, Mar 19, 2021

If I remember correctly, before mix 6 there was no mix command, therefore you maybe just did not encounter an underlaying problem. It is very likely that the problem is not mix specific. As your OS is Win 10 and the error comes from sh it seems you somehow messed up with WSL and cmd/powershell?

I know the issue in general and few of my problems in the past were:

  • npm install with cmd/powershell but then npm run ... in WSL: The files created in node_modules/.bin are somehow not correct (I think it has to do with linux/windows links and shell-scripts)
  • check whether node_modules/.bin is created and you find a mix and mix.cmd and mix.ps1 in it (after npm i from powershell)
  • run npx mix on your console in your project root, see if that works

Another ugly issue I had was, that somehow node wanted to do something in global installed packages (even though I did install them locally). Then (in good dirty windows manner) there was a file path somewhere in my %USERPROFILE% directory, whereas my username was like “Firstname Lastname” which then caused problems due to the whitespace.

But as I said, to what you wrote that seem not to be mix-related.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Laravel, NPM: Command "mix" not found - Stack Overflow
I tried many solutions but only this worked for me: First, update your laravel-mix npm install laravel-mix@latest.
Read more >
sh: 1: mix: not found · Issue #2903 - GitHub
Have tried updating Laravel Mix to the latest versions. I'm using --no-bin-links because npm install never works without it. Laravel 7 and Mix...
Read more >
mix: command not found (Laravel) error [Solved] | bobbyhadz
To solve the error "mix: command not found", make sure to install the laravel-mix package by opening your terminal in your project's root...
Read more >
mix: not found - Laracasts
Fresh installation of laravel 8, Jetstream and Livewire and I'm getting below error. How to resolve it? Thank you. npm run dev. @...
Read more >
[Solved]-Laravel, NPM: Command "mix" not found-laravel
Best method to fix mix not found error is to reinstall npm using the command: npm clean-install. Digi Coder 56. score:8. You will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found