How to fix Webpack when it can’t find your modules

Then, here are the steps to fixing it:
First, run Webpack with the ‘–display-error-details’ like so:webpack --progress --color --watch --display-error-details
In my case, webpack is automatically run when I run npm run dev, so I had to make the change in my package.json file.

Now when you run Webpack, you’ll get a far clearer idea of what is actually wrong. Here are some possible issues / fixes:
There may be a typo in your webpack.config – make sure everything looks right. Check it twice.

Your webpack.config could be missing a key detail / config. This was ultimately what was causing the error for me (details below).

If the module that Webpack is unable to find was written by you, make sure that the file names don’t have any trailing spaces. For example, it is very difficult to see the difference between ‘myfile.js’ and ‘myfile.js ‘. The latter has a space after it.

If Webpack is unable to find a third-party module such as react or redux, make sure that it is actually installed. Run npm install --save missing_module_name (replace ‘your_module_name with the actual module’s name) just to be sure.

but that wasn’t it, I was getting this for all 3rd party modules I was importing from even though they were installed correctly.

Finally, after some digging, I found that we could get more verbose errors out of Webpack by adding the –display-error-details flag. What’s awesome about this flag is that Webpack will list all the paths it used to find the missing module. In my case these were:

So, there was something wrong with how I was telling Webpack to resolve file extensions. I was using: resolve: {
extensions: ['.js', '.jsx'],
},
when it should have been resolve: {
extensions: ['', '.js', '.jsx'],
},
which, fixed the problem.