Hi HashNoders.,
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.
Are you doing somewhere import "window" or require("window")? I think webpack calls modules only to files you are importing...
Somasundaram Ayyappan
Put
target: 'web'in your webpack config file, this will make browser variables likewindowand others available to webpack.