Entry module not found: Error: Can't resolve './src/index.js'

Your base URL is path.join(__dirname, "public"), and your entry is ./src/index.js. Webpack tries to find ./src/index.js in public dir; obviously it does not exist. You should modify entry to ../src/index.js.


The other way I find out to fix this problem is to use path.resolve().

const path = require('path');
module.exports = {
    mode: "production",
    entry: path.resolve(__dirname, 'src') + 'path/to/your/file.js',
    output: {
        /*Webpack producing results*/
        path: path.resolve(__dirname, "../src/dist"),
        filename: "app-bundle.js"
    }
}

This will make sure, webpack is looking for entry point in src directory.

By the way it's the default entry point. You can also change this entry point to your suitable location. Just replace the src directory with the other directory you want to use.