Closed mshtang closed 1 year ago
you cannot use import Mdict from 'js-mdict'
directly, you should do this:
const Mdict = require('js-mdict');
const dict = new Mdict.default('./testDict/data.mdx'); <= you should use Mdict.default;
console.log('lookup red', dict.lookup('red'));
or you can use babel or webpack to compile es6 to commonjs syntax to run at bare node environment
Thank you for the speedy response. Using new Mdict.default(...)
solves the problem.
Hi, I am trying out this module but got a
TypeError: Mdict is not a constructor
.I tested it this way: create a
main.js
file,npm install js-mdict
, add the following lines to the script file and run it in the console bynode main.js
. I tried with node v17.3 and v18.15 but neither worked out for me.Am I using the module correctly?
Thank you for your help!