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

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

0

Try using

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