Laravel-mix: TypeError: Cannot convert undefined or null to object?

Created on 21 Jan 2019  路  1Comment  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: "^4.0.14"
  • Node Version: 8.14.0
  • NPM Version: 6.4.1

In a laravel 5.6/reactjs app, after upgrading laravel-mix from version 2 to "laravel-mix": "^4.0.14", when I run npm run development I get the below error:

> npm run development
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

/home/mydomain.com/node_modules/webpack-cli/bin/cli.js:235
                throw err;
                ^

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at mergeObject (/home/mydomain.com/node_modules/deepmerge/dist/umd.js:55:9)
    at deepmerge (/home/mydomain.com/node_modules/deepmerge/dist/umd.js:79:10)
    at reduce (/home/mydomain.com/node_modules/babel-merge/dist/index.js:30:44)
    at Array.reduce (<anonymous>)
    at mergeArray (/home/mydomain.com/node_modules/babel-merge/dist/index.js:20:36)
    at babelMerge (/home/mydomain.com/node_modules/babel-merge/dist/index.js:40:19)
    at values.reduce (/home/mydomain.com/node_modules/babel-merge/dist/index.js:60:26)
    at Array.reduce (<anonymous>)
    at Function.value (/home/mydomain.com/node_modules/babel-merge/dist/index.js:58:49)
    at Function.generate (/home/mydomain.com/node_modules/laravel-mix/src/BabelConfig.js:11:22)
    at Object.babel (/home/mydomain.com/node_modules/laravel-mix/src/config.js:121:45)
    at React.webpackRules (/home/mydomain.com/node_modules/laravel-mix/src/components/JavaScript.js:76:41)
    at ComponentFactory.applyRules (/home/mydomain.com/node_modules/laravel-mix/src/components/ComponentFactory.js:155:23)
    at Mix.listen.rules (/home/mydomain.com/node_modules/laravel-mix/src/components/ComponentFactory.js:66:48)
    at events.(anonymous function).forEach.handler (/home/mydomain.com/node_modules/laravel-mix/src/Dispatcher.js:34:47)
    at Array.forEach (<anonymous>)
    at Dispatcher.fire (/home/mydomain.com/node_modules/laravel-mix/src/Dispatcher.js:34:28)
    at Mix.dispatch (/home/mydomain.com/node_modules/laravel-mix/src/Mix.js:119:25)
    at WebpackConfig.buildRules (/home/mydomain.com/node_modules/laravel-mix/src/builder/WebpackConfig.js:83:13)
    at WebpackConfig.build (/home/mydomain.com/node_modules/laravel-mix/src/builder/WebpackConfig.js:23:14)
    at Object.<anonymous> (/home/mydomain.com/node_modules/laravel-mix/setup/webpack.config.js:29:38)
    at Module._compile (/home/mydomain.com/node_modules/v8-compile-cache/v8-compile-cache.js:178:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (/home/mydomain.com/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at WEBPACK_OPTIONS (/home/mydomain.com/node_modules/webpack-cli/bin/convert-argv.js:115:13)
    at requireConfig (/home/mydomain.com/node_modules/webpack-cli/bin/convert-argv.js:117:6)
    at /home/mydomain.com/node_modules/webpack-cli/bin/convert-argv.js:124:17
    at Array.forEach (<anonymous>)
    at module.exports (/home/mydomain.com/node_modules/webpack-cli/bin/convert-argv.js:122:15)
    at yargs.parse (/home/mydomain.com/node_modules/webpack-cli/bin/cli.js:232:39)
    at Object.parse (/home/mydomain.com/node_modules/webpack-cli/node_modules/yargs/yargs.js:567:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
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!     /home/.npm/_logs/2019-01-21T18_30_16_092Z-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!     /home/.npm/_logs/2019-01-21T18_30_16_106Z-debug.log

I tried for a whole day to fix it and can't figure out how to get past this error to compile successfully.

Any idea how to fix this error so we can compile the app?

Most helpful comment

Figured it out, in .babelrc I wrapped a babel-plugin-name with [] without any options being passed. Once I removed the brackets, everything worked okay :)

>All comments

Figured it out, in .babelrc I wrapped a babel-plugin-name with [] without any options being passed. Once I removed the brackets, everything worked okay :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mstralka picture mstralka  路  3Comments

hasnatbabur picture hasnatbabur  路  3Comments

kpilard picture kpilard  路  3Comments

mementoneli picture mementoneli  路  3Comments

jpriceonline picture jpriceonline  路  3Comments