Module not found: Error: Cannot resolve module ‘babel-loader’

I’m using webpack in directory /users/path/a/(it holds the webpack.config.js) and compile files in directlry /another/path/b/. I run gulp webpack task in path a, and it will compile all the files in path b using absolute path.

Then I got Cannot resolve module 'babel-loader' error.

After looking at #784, I tried resolve.fallback, resolve.root, but neither works. Thanks for all kinds of help.

Author: Fantashit

7 thoughts on “Module not found: Error: Cannot resolve module ‘babel-loader’

  1. Changed to resolveLoader.root
    BTW, it’s hard to find resolveLoader.root in the documentation. the IMPORTANT is not so outstanding


  2. For those looking to have some copy pasta:

    resolveLoader: {
      root: path.join(__dirname, 'node_modules')

    Pulled from the docs and the image as posted by @camsong. Thanks for figuring it out.

  3. Kevinreilly – I tried the suggestion you gave. I can see where you found it in the docs, but it produces this error for me: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

    • configuration.resolveLoader has an unknown property ‘root’. These properties are valid:
      object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }
  4. @MincePie after researching your error it seems like the solution above is for Webpack v1 and that it may have changed for v2. I’ve not used v2 so this is just a guess from the migration guide:

      resolve: {
       modules: [
         path.join(__dirname, "src"),

    For more information, see Migrating from v1 to v2

  5. In my case my node_modules folder is in a different location, and only modifying resolve.modules didn’t work well with webpack-dev-server.

    This worked for me:

    resolveLoader: {
        modules: ['/path/to/node_modules'],
    resolve: {
        modules: ['/path/to/node_modules'],

Comments are closed.