Error in npm run dev

Asked

Viewed 945 times

0

I’m trying to execute command npm run dev in a project developed by another person. This is the configuration in package.json:

"scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "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 --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 --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},

And this is the mistake:

node_modules/webpack-cli/bin/cli.js:93
                throw err;
                ^
TypeError: Cannot read property 'config' of undefined

The project is in Laravel and uses webpack. I have already tried to remove the npm packages and reinstall them, cleaned the cache, reinstalled Node, updated the packages, but nothing helped. How could I correct?

  • adds the app code.js

  • I don’t have that file on the project.

  • Without the code it’s hard to help

1 answer

1

I managed to fix it, I’ll put the answer here, maybe help someone with the same problem.

edit the line:

const { mix } = require('laravel-mix')

for this:

const mix = require('laravel-mix')

Browser other questions tagged

You are not signed in. Login or sign up in order to post.