Laravel-mix: Error on npm run dev with Laravel Project

Created on 10 Jan 2021  ·  28Comments  ·  Source: JeffreyWay/laravel-mix

Hi,

I get following error when i am try to run npm run dev command on windows power-shell

@ development C:\Users\Praneeth Gamage\Desktop\Laravel_Projects\posty
mix

[webpack-cli] Running multiple commands at the same time is not possible
[webpack-cli] Found commands: 'bundle', 'Gamage\Desktop\Laravel_Projects\posty\node_modules\laravel-mix\setup\webpack.config.js'
[webpack-cli] Run 'webpack --help' to see available commands and options
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ development: mix
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Praneeth Gamage\AppData\Roaming\npm-cache_logs\2021-01-10T12_30_36_179Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ dev: npm run development
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Praneeth Gamage\AppData\Roaming\npm-cache_logs\2021-01-10T12_30_36_230Z-debug.log

bug help wanted

Most helpful comment

I already solved it, in my case, it was the blank spaces in the path to the project

All 28 comments

I have the same problem right now. Even npx mix doesn't work and the command cannot be found. I'm using it on windows.

I have the same problem.
NPM v6.14.11
Mix v6.0.9
Also on Windows.

Guess they have only tested it on linux and mac. 😃

The tests run on Node 12, 13, and 14 on Linux and Windows. I'm gonna take a look at this at some point soon. We're quoting the path to the webpack config file in the CLI to fix this very problem on Windows. It seems like something is causing the quotes to be removed.

I have the same problem, is there a solution?

i have the same problem

image

I already solved it, in my case, it was the blank spaces in the path to the project

@fikrisuheri verify that this path is complete, if it is cut it is because of the blank spaces, the solution is to move the project from place to a path that does not have spaces.
image

@fikrisuheri verify that this path is complete, if it is cut it is because of the blank spaces, the solution is to move the project from place to a path that does not have spaces.

thanks, i will try it

@fikrisuheri verify that this path is complete, if it is cut it is because of the blank spaces, the solution is to move the project from place to a path that does not have spaces.
image

Thank you adrian! this solved my issue!
i also have the same problem for the last 3 days and can't solved it, but now it's solved thanks to you

@fikrisuheri verify that this path is complete, if it is cut it is because of the blank spaces, the solution is to move the project from place to a path that does not have spaces.
image

Thanks Lot. It solve my problem. Cheers !

image

What commands have to be run in order to make it work?
I ran npm upgrade and also npm update and then npm run dev.

````
🚀❯ npm run dev

@ dev D:\code\dnw\hannibal\src

@ development D:\code\dnw\hannibal\src
mix

Der Befehl "mix" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: mix
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Alex\AppData\Roaming\npm-cache_logs\2021-01-11T11_18_48_485Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: npm run development
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Alex\AppData\Roaming\npm-cache_logs\2021-01-11T11_18_48_511Z-debug.log
````

The content of my package.json:
json { "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": { "@tailwindcss/forms": "^0.2.1", "@tailwindcss/typography": "^0.3.0", "alpinejs": "^2.7.3", "autoprefixer": "^10.2.1", "axios": "^0.21", "chokidar": "^3.5.0", "chokidar-cli": "^2.1.0", "cross-env": "^7.0.3", "esbuild": "^0.8.31", "laravel-mix": "^6.0.6", "lodash": "^4.17.19", "postcss": "^8.2.4", "postcss-custom-properties": "^10.0.0", "postcss-import": "^12.0.1", "postcss-nested": "^5.0.3", "precss": "^4.0.0", "tailwindcss": "^2.0.2" } }

Guess I will move it to a different issue as my issue is a little different.

@emineinnovations I'd keep this issue open, as the bug that causes Laravel Mix to fail on Windows when there's a space in the path is not resolved yet.

@wickex Sure..

Same issue, new project. Old ones still work.

I'm having the same issue since version 6. Older versions work fine.

I can't reproduce this issue on Windows 10. Can you all post which versions of Windows and Node you are using?

Node: 12.19.0
NPM: 6.14.8
Windows: 10 / 2004

I've reproduced the issue but I'm not sure what's wrong yet.

Two things I've discovered:

  1. The generated command is quoted correctly (you can check this by running .\node_modules\.bin\cross-env TESTING=1 npm run dev)
  2. This does not happen if you install dependencies via yarn. Regardless if you run them via yarn, npm, or npx afterwards.

NPM: 6.14.11
Node: 12.18.3
Windows: 10 20H2 19042.685
Laravel: 8.5.7

I noticed that removing spaces in the directory solved this issue. But it's still a temporary solution since I'm not feeling like editing all my GITs now.

Best I can tell this has nothing to do with Mix. Our CLI script just triggers the error in node/npm and apparently npm run scripts bypass this somehow. I'm trying to see if there's a workaround we can implement.

It appears that the scripts written by yarn in node_modules/.bin pass arguments with spaces correctly to node but the scripts written by npm do not.

I already solved it, in my case, it was the blank spaces in the path to the project

really really ty bro u saved me <3 @adrian250997

To anyone who's still not able to run the "npm run dev" command. Make sure to run the command through the debugger a few times, and it should fix the problem.

Yup this error still exists, however I was able to minimize it by doing the following:

  1. npm i webpack (it seems webpack was NOT installed and missing in package.json)
  2. removing '--hide-modules' from "Scripts":"development" in package.json eliminated another error

20200331-webpack-is-now-compiling

After doing those two things I got all the way through 98% compilation and then it fails on this:

× Mix
  Compiled with some errors in 26.16s

ERROR in ./resources/js/components/ExampleComponent.vue 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <template>
|     <div class="container">
|         <div class="row justify-content-center">

webpack compiled with 1 error

I'm running down this last error now. Hopefully this can be easily resolved.

This issue is solved for me.

@drsavant-pub from the code you posted, I see you are using Vue.js. Webpack does not automatically load Vue, so you need to install its loader: https://vue-loader.vuejs.org/

@scajal Thank for your help, but I've decided to let Laravel sort out their own issues. (If I require Laravel I'll install an earlier version. One that I know works.) For now I'm using CodeIgniter 4 and it works great!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rderimay picture rderimay  ·  3Comments

jpmurray picture jpmurray  ·  3Comments

nezaboravi picture nezaboravi  ·  3Comments

Bomavi picture Bomavi  ·  3Comments

pixieaka picture pixieaka  ·  3Comments