My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Webpack - Error: Cannot resolve module 'window'

VignesH KumaR's photo
VignesH KumaR
·Jun 16, 2016

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.