Reputation: 105
When I run my code in RunKit, it outputs "TypeError: mml2tex is not a function" in the console.
Here's the link for the code: https://runkit.com/embed/4rnhdcgjrzwl
var mml2tex = require("mml2tex")
const mml = `
<math xmlns="http://www.w3.org/1998/Math/MathML">
<msqrt>
<mn>2</mn>
</msqrt>
</math>
`;
const tex = mml2tex(mml);
console.log(tex);
How do I fix this?
Upvotes: 0
Views: 78
Reputation: 9630
you need to change the way you are importing the package.
const mml2tex = require('mml2tex').default;
const mml = `<math xmlns="http://www.w3.org/1998/Math/MathML">
<msqrt>
<mn>2</mn>
</msqrt>
</math>
`;
const tex = mml2tex(mml);
console.log(tex);
notice the extra .default
when using the commonjs method.
more information in this answer: module.exports vs. export default in Node.js and ES6
Upvotes: 0