I've had a similar issue in the past, if it is in fact the same problem here's how to solve it.

The require you have shown is within the wrapping IIFE, which means that this is not window but the function, meaning that when you try to find require it's not in scope. In order to fix this you need use imports-loader.

In your case, under module and then loaders, add:

    test: require.resolve("/*require/import path which requires the file where require("url") is*/"), 
    use: "imports-loader?this=>window"

Hope this solves your problem.


You need to use something like browserify or babelify.

See a more in-depth explanation here.

Related Query

More Query from same tag