Error : ERROR in Entry module not found: Error: Cannot resolve ‘file’ or ‘directory’…

Hi everybody.

I’m simply trying to use webpack but i can’t solve this error.

This is my webpack.config.js :

module.exports = {
  entry: './index.js',
  output: {
    filename: 'bundle.js'
  }
};

I try many thing but nothing change… I’m using last version of webpack 1.8.4.

I got this error :

Running "webpack:build-dev" (webpack) task
Version: webpack 1.8.4

ERROR in Entry module not found: Error: Cannot resolve 'file' or 'directory' ./index.js in D:\myApp\src
Warning: Task "webpack:build-dev" failed. Use --force to continue.

index.js file is in src folder…

Anybody got an idea ?

Author: Fantashit

16 thoughts on “Error : ERROR in Entry module not found: Error: Cannot resolve ‘file’ or ‘directory’…

  1. Had this error today. I’m commenting here because this is the first hit in Google with the error message.

    There was nothing wrong with my webpack.config.js but there was a syntax error in my package.json which caused this. Better error message would be cool.

    This error has been seen here too ryanclark/karma-webpack#33

  2. Thanks @epeli! Spent a while looking through my gulpfile.js when I had a comma on the last item in my devDependencies in package.json

    Terrible error message

  3. For those arriving by search: I had this issue because I was using html-loader in my webpack config, and had requires prefixed with html!. This caused my options in the config to get ignored for every file.

  4. Why does not webpack print such obvious errors as unability to parse package.json?
    my package.json was corrupted and webpack gave me mysterious errors about unability to resolve absolute path…

    1. Restart Terminal(Mac) or whatever shell in your environment.
    2. Add FIXFIX in package.json like this:
      "scripts": { "FIXFIX": "webpack --progress --profile --colors --display-error-details --display-cached", },
    3. Run this: (Yes, with sudo!)
      sudo node run FIXFIX
    4. Now run with your normal build see if it fixed.
  5. I think it has to do with the new webpack version where you have to specify “resolve”.
    My project didn’t work until I added it this line:
    resolve: { modulesDirectories: ['node_modules', 'src'], extension: ['', '.js', '.scss'] },

Comments are closed.