Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Invalid configuration object in Webpack


[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration[0].entry['js/widgets.bundle'] should be a non-empty array.
-> All modules are loaded upon startup. The last one is exported.
error Command failed with exit code 2.

I have found that the entries['js/widgets.bundle'] are returning an empty array instead of widgets paths.

// Widgets js
entries['js/widgets.bundle'] = glob.sync(entryPattern).map(file => file.replace(/\\/g, '/'));

System config:
Node Version: v21.5.0
Package Manager: Yarn


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (6)


I'm glad to hear that you were able to resolve the issue! Thank you for the update. We'll make sure to address this in the upcoming updates to improve compatibility with Windows machines. If you have any more questions or need further assistance, feel free to ask.



Thanks to all of you. I have solved the issue by replacing the "forward slash (/)" with "double backward slash (\\)" for Windows machines. Now it's working fine.


I had exactly the same issue, after replacing the code block, npm run build starts building but failed.

Threw this:

>> Failed to compile!

resolve 'dropzone/dist/min/dropzone.min.js' in 'D:\Metronic_demo1_HTML5\tools\webpack\plugins'
 Parsed request is a module
 using description file: D:\Metronic_demo1_HTML5\tools\package.json (relative path: ./webpack/plugins)
 Field 'browser' doesn't contain a valid alias configuration
 resolve as module
 D:\Metronic_demo1_HTML5\tools\webpack\plugins\node_modules doesn't exist or is not a directory
 D:\Metronic_demo1_HTML5\tools\webpack\node_modules doesn't exist or is not a directory
 looking for modules in D:\Metronic_demo1_HTML5\tools\node_modules
 existing directory D:\Metronic_demo1_HTML5\tools\node_modules\dropzone
 using description file: D:\Metronic_demo1_HTML5\tools\node_modules\dropzone\package.json (relative path: .)
 using description file: D:\Metronic_demo1_HTML5\tools\node_modules\dropzone\package.json (relative path: ./dist/min/dropzone.min.js)
 no extension
 Field 'browser' doesn't contain a valid alias configuration
 D:\Metronic_demo1_HTML5\tools\node_modules\dropzone\dist\min\dropzone.min.js doesn't exist
 .js
 Field 'browser' doesn't contain a valid alias configuration
 D:\Metronic_demo1_HTML5\tools\node_modules\dropzone\dist\min\dropzone.min.js.js doesn't exist

So I corrected the dropzone file in two files:

  1. plugins.bundle.js
  2. plugins.js

From node_modules/dropzone/dist/min/dropzone.min.js

To: node_modules/dropzone/dist/dropzone-min.js

Finally I got:

>> Building...
 >> Completed in 14.591s!
 webpack compiled successfully

Hi Amin,

Apologies for the delay. We're working on fixing the issue you reported. Could you please try making the following change?

const entryPattern = path.join(srcPath, "js/widgets/**/*.js");
// Widgets js
entries["js/widgets.bundle"] = (glob.sync(path.relative("./", srcPath).replaceAll(/\\/g, "/") + "/js/widgets/**/!(_)*.js") || []).map(file => {
return file.replaceAll(/\\/g, "/");
});


Please replace the existing code block with this updated snippet.

entries["js/widgets.bundle"] = (glob.sync(path.relative("./", srcPath).replaceAll(/\\/g, "/") + "/js/widgets/**/!(_)*.js") || []).map(file => {
return file.replaceAll(/\\/g, "/");
});


Let us know if this resolves the issue. Thank you for your patience.

Thanks



Hi Amin,

I apologize for the inconvenience. Could you please confirm whether you are using Windows? We will investigate and address the issue accordingly.

Thanks



I am on window 11


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(