close

[Solved] Entry module not found: Error: Can’t resolve ‘./src/index.js’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Entry module not found: Error: Can’t resolve ‘./src/index.js’ in javascript. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Entry module not found: Error: Can’t resolve ‘./src/index.js’ Error Occurs?

Today I get the following error Entry module not found: Error: Can’t resolve ‘./src/index.js’ in javascript.

How To Solve Entry module not found: Error: Can’t resolve ‘./src/index.js’ Error ?

  1. How To Solve Entry module not found: Error: Can't resolve './src/index.js' Error ?

    To Solve Entry module not found: Error: Can't resolve './src/index.js' Error 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.

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

    To Solve Entry module not found: Error: Can't resolve './src/index.js' Error 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.

Solution 1

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.

Solution 2

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.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment