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