Zahid Mzhmm
Zahid Mzhmm

Reputation: 71

Laravel 8 Installation - npm run dev Error

[webpack-cli] Error: mix.react() is now a feature flag. Use mix.js(source, destination).react() instead
   at React.register (F:\Server\work\reactlaravel\lrpc1\node_modules\laravel-mix\src\components\React.js:15:19)
   at Object.components.<computed> [as react] (F:\Server\work\reactlaravel\lrpc1\node_modules\laravel-mix\src\components\ComponentRegistrar.js:118:53)
   at Object.<anonymous> (F:\Server\work\reactlaravel\lrpc1\webpack.mix.js:14:5)
   at Module._compile (F:\Server\work\reactlaravel\lrpc1\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
   at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
   at Module.load (internal/modules/cjs/loader.js:985:32)
   at Function.Module._load (internal/modules/cjs/loader.js:878:14)
   at Module.require (internal/modules/cjs/loader.js:1025:19)
   at require (F:\Server\work\reactlaravel\lrpc1\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
   at module.exports (F:\Server\work\reactlaravel\lrpc1\node_modules\laravel-mix\setup\webpack.config.js:3:5)
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\info\AppData\Roaming\npm-cache\_logs\2021-01-06T04_36_25_320Z-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\info\AppData\Roaming\npm-cache\_logs\2021-01-06T04_36_25_340Z-debug.log

Upvotes: 7

Views: 32153

Answers (5)

Mahan Mashoof
Mahan Mashoof

Reputation: 189

Had the same problem, just removed node_modules and installed it again successfully:

rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install
npm run dev

source: https://github.com/JeffreyWay/laravel-mix/issues/1072

Upvotes: 1

lemonsprites
lemonsprites

Reputation: 53

I found the same problem before and try this :

  1. Delete node_modules folder and package-lock.json
  2. reinstall package using npm install
  3. Try run npm run dev again.

For the details see https://github.com/laravel-mix/laravel-mix/issues/2774.

Upvotes: 3

Mayur Trivedi
Mayur Trivedi

Reputation: 121

To fix this issue you need to replace this code.

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

With the following code in the webpack.mix.js file which you can find in the Laravel app root directory.

mix.js('resources/js/app.js', 'public/js')
    .react()
    .sass('resources/sass/app.scss', 'public/css', [
    //
    ]);

These changes are rolled up in Laravel Mix v6. Read the following for further changes. https://github.com/JeffreyWay/laravel-mix/blob/628f6062cceb77610b1813e3179abcbd043a4642/UPGRADE.md#update-your-npm-scripts

Upvotes: 12

Haikal
Haikal

Reputation: 1

try to run

npm install

then run

npm install && npm run dev

it help me to solved this problem, btw im using laravel 8

Upvotes: 0

Dean
Dean

Reputation: 31

try to change the script in package.json

"scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "npm run development -- --watch",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --config=node_modules/laravel-mix/setup/webpack.config.js"
},

Upvotes: 3

Related Questions