Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
Why am I getting Webpack 'module not found' error?

I am refactoring project which has a working webpack bundling. Basically, I am trying to change the root source folder of the project and I am having an issue. I have been debugging for so long but I cannot see what I am missing.

In my tsconfig.json file I have the following settings

    "baseUrl": "./",
    "paths": {
        "src/*": [
            "src/*"
        ],
        "test/*": [
            "test/*"
        ]
    }

In the webpack.common.js file I have the following

const includePaths = ['node_modules', 'src'];
resolve: {
    extensions: ['.ts', '.tsx', '.js', '.jsx'],
    modules: includePaths,
},

My source folder is in the root of my project. Basically I should be able to reach with ./src

This is how I bundle:

rm -rf ./build && webpack --config webpack.dev.js

webpack.dev.js

merge(common, config, {
    entry: {
        main: [
            `${__dirname}/src/environment`,
            'webpack-hot-middleware/client?path=__webpack_hmr&dynamicPublicPath=true',
            `${__dirname}/src/main`,
        ],
    },

When I run the bundler in watch mode I see something like:

These dependencies were not found:
src/<somefolder>/<somefile> in ./src/<somefolder>/<somefile.tsx>

Module not found: Error: Can't resolve ...

The weird thing is, when src folder was under another folder eg. frontend/src, it was bundling without an issue. I suspect something is off in the tsconfig but I cannot figure it out. Can someone please help?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Adding alias like this worked but I don't really understand how old version was working without the alias.

        alias: {
            src: path.resolve(__dirname, 'src'),
        },
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!