VignesHKumaR
VignesHKumaR

Reputation: 159

Webpack - Error: Cannot resolve module 'window'

I am facing the following error when tried using Webpack for my project.

"Module not found: Error: Cannot resolve module 'window'."

I have few places in JS files where in which I need to set some values to the global 'window' object and use the same in other places.

Ex:

window.bridge = new Bridge();
var _bridge = window.bridge;

When trying to Webpack all these JS files, the above mentioned error occurs.

I think the problem is because the Webpack bundler sees the 'window' object as one another module to load like loading other node modules like underscore, lodash, etc.,

Any idea on this, guys ??

Appreciate your help, in advance.

Upvotes: 1

Views: 1833

Answers (1)

Jigar
Jigar

Reputation: 544

For any global values, you can use externals for example

externals: {
  "window":"window"
 } 

Upvotes: 1

Related Questions