Webpack-cli - TypeError: Cannot convert undefined or null to object

Viewed 4556

I'm trying to build yarn build

but i'm having the following error

    yarn run v1.22.4
$ webpack --progress --config resources/assets/build/webpack.config.js


  \wp-content\themes\portfolio\node_modules\webpack-cli\bin\cli.js:93
                                    throw err;
                                    ^

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at mergeTo (\wp-content\themes\portfolio\node_modules\webpack-merge\dist\merge-with.js:30:24)
    at \wp-content\themes\portfolio\node_modules\webpack-merge\dist\merge-with.js:23:15
    at Array.forEach (<anonymous>)
    at Object.mergeWith [as default] (\wp-content\themes\portfolio\node_modules\webpack-merge\dist\merge-with.js:22:10)
    at mergeWithOptions (\wp-content\themes\portfolio\node_modules\webpack-merge\dist\index.js:71:39)

in my config.js im importing webpack-cli

const { merge } = require('webpack-merge');

Here's the version of webpacks

 "webpack": "~4.44.2",
"webpack-assets-manifest": "^3.1.1",
"webpack-cli": "^3.3.12",
"webpack-merge": "~5.1.4",

started having this issue once i updated webpack-cli version

1 Answers

All it is saying is that it expects an object of some type but it has null as the object may be set to null. The code is expecting an object of some type but it is either undefined or null. This object could also be an array which does not contain the particular member it is looking for because it is too short for example or the array does not exist to begin with. Since you updated the weback cli version you probably had to update something else for it to work properly but you did not, maybe that is why some code is missing to initialise this object or array.

This error is happening at the file : \wp-content\themes\portfolio\node_modules\webpack-cli\bin\cli.js:93 at line 93 of the file if you can check that line and display it would be great.

Also have a look at the other files mentioned: TypeError: Cannot convert undefined or null to object at Function.keys () at mergeTo (\wp-content\themes\portfolio\node_modules\webpack-merge\dist\merge-with.js:30:24) at \wp-content\themes\portfolio\node_modules\webpack-merge\dist\merge-with.js:23:15 at Array.forEach () at Object.mergeWith [as default] (\wp-content\themes\portfolio\node_modules\webpack-merge\dist\merge-with.js:22:10) at mergeWithOptions (\wp-content\themes\portfolio\node_modules\webpack-merge\dist\index.js:71:39)

Maybe you are merging the wrong webpack cli versions together.

Related