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

229
Vistas
I'm trying to require file in webpack enviroment, but the a varible path make an error
    this.data = require("/static/content/" + this.place + "/main.json")

This is work.

    this.path = "/static/content/" + this.place
    this.data = require(this.path + "/main.json")

This is bad.

The error look like this:

Uncaught Error: Cannot find module '/static/content/Suzanne/main.json'
at webpackEmptyContext (.json$:2:1)
at EExplore.init (EExplore.js:9:21)
at new EExplore (EExplore.js:3:1)
at Module.1213 (explore.js:5:1)
at __webpack_require__ (bootstrap:24:1)
at __webpack_exec__ (explore.js:39:1)
at explore.js:39:1
at Function.__webpack_require__.O (chunk loaded:23:1)
at explore.js:39:1
at webpackJsonpCallback (jsonp chunk loading:521:1)

I'm really confused.

Is there any difference between these two forms?

My webpack config file is here if you needed

    devServer: {
    watchFiles: ["src/**", "static/**"],
    static: {
        watch: true,
        directory: path.join(__dirname, "./static"),
    },
},
plugins: [
    ...
    new CopyWebpackPlugin({
        patterns: [
            {
                from: path.resolve(__dirname, "./static"),
                to: "static/",
            },
        ],
    }),
about 4 years ago · Juan Pablo Isaza
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