Webpack 4 : ERROR in Entry module not found: Error: Can't resolve './src'

Resolved

Spent a lot of time to find out the solution.

Solution: Add index.js file into src folder.

That's it!.. solved :)


During Research, I found some facts about webpack 4 :

webpack 4 doesn’t need a configuration file by default!

webpack 4 there is no need to define the entry point: it will take ./src/index.js as the default!


Met this problem when deploying on now.sh

Solution: Use Default Behavior

Move entry point to src/index.js.

This leverage webpack@4 default value for entry:

By default its value is ./src/index.js, but you can specify a different (or multiple entry points) by configuring the entry property in the webpack configuration.

Solution: Be Specific

As @Lokeh pointed out, if you don't want to change your JS file location you can always use path.resolve() in your webpack.config.js:

entry: path.resolve(__dirname, 'src') + '/path/to/your/file.js',

webpack ./src/js/app.js --output ./dist/app.bundle.js --mode development

This worked for me. I had the same trouble, it is because of a new version of webpack