Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

162
Views
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 answers
Answer question

0

Try using

import * as i18next from 'i18next';
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!