Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

401
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda