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

408
Visualizações
Can't figure out how to use webpack's require.context()

I have an AngularJS with webpack project, and I want to import all the .js files in my project to webpack without adding the path of each file individually, so on the webpack docs I found this require.context() and it looked straight forward, but for some reason I keep getting this error:

webpackEmptyContext(req) {
    var e = new Error("Cannot find module '" + req + "'");
    e.code = 'MODULE_NOT_FOUND';
    throw e;
}

This is how the function is declared, I used the same example that they gave on the docs:

function importAll(r) {
  console.log(r)
  r.keys().forEach(r);
}

importAll(require.context('./src', true, /\.js$/));

I'm using node 10 and webpack 5.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The path argument in the require.context call is relative to your file that declared the function. If the file that calls require.context is deep in your src directory, you may try locating your src directory by something like ../../../../src and put this string into the argument.

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