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

165
Vistas
NodeJS import NPM module

I have a .js file that I am trying run through node. The problem that I am having is that my file requires an import of i18next. Node of course does not like this.

I have already added "type":"module to my package.json. Inside my file accessLayer.js I am trying to import i18next as:

import i18next from 'i18next'; const {languageTranslate} = i18next;

For my code inside my terminal I am running:

>node --experimental-repl-await
>var aa
>import("./app/accessLayer.js").then(loaded => aa = loaded)

if I console.log() aa it returns [Module: null prototype] { }.

Inside my file is a modules.export which has an authenticate that I am trying to access.

Now, if I completely remove the i18next import from accessLayer.js. I can then run:

>node
>var x
>var y
>var x = require('./app/accessLayer.js')
> var y = x()
> y.authenticate('xxxx')

This way does work, however, then I do not have access to i18next, which is needed. Any advice or direction is greatly appreciated. My version of node is: 14.17.6.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try using

import * as i18next from 'i18next';
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