Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

219
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda