pkra / mathjax-node-page

mathjax-node for pages
Apache License 2.0
42 stars 20 forks source link

Cannot set property 'defaultEx' of undefined with TeX-AMS_SVG.js config #42

Closed tuanmh closed 7 years ago

tuanmh commented 7 years ago

Hi there,

Thanks again for a great library! We're currently having this problem:

Error: TypeError: Cannot set property 'defaultEx' of undefined
    at StartQueue (/Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax-node/lib/main.js:676:35)
    at Function.execute (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:243:26)
    at cb (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:225:59)
    at Process (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:495:38)
    at call (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:508:37)
    at Function.WAITEXECUTE (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:348:50)
    at cb (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:225:59)
    at Process (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:495:38)
    at call (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:508:37)
    at Function.WAITEXECUTE (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:348:50)
    at cb (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:225:59)
    at Process (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:495:38)
    at call (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:508:37)
    at Function.WAITEXECUTE (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:348:50)
    at cb (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:225:59)
    at Process (file:///Users/tuanhuynh/projects/monash-alexandria/mathjax-serverless/functions/node_modules/mathjax/unpacked/MathJax.js:495:38)

The code is as simple as this:

'use strict';

let mjNodePage = require("mathjax-node-page");

/*Start MathJax, great for container reuse*/
const mjnodeConfig = {
    svg: true,
    linebreaks: true
};

const pageConfig = {
    format: ["TeX"],
    MathJax: {
        config: ["TeX-AMS_SVG.js"]
    }
};

exports.default = function(event, context, callback) {
    try{
        mjNodePage.mjpage(event.body, pageConfig, mjnodeConfig, function(output) {
            console.log(output);
        });
    } catch(ex){
        console.error(ex);      
    }

};

Could you please give us a hand on this? Should we use TeX-AMS_SVG.js configuration for transforming TeX to SVG? Thanks again!

tuanmh commented 7 years ago

By the way, we're using node 6.10

pkra commented 7 years ago

Thanks for the report.

Should we use TeX-AMS_SVG.js configuration for transforming TeX to SVG?

No, there's no need for that.

Removing this piece seems to fix the issue for now.

I suspect this is an upstream issue (to be fixed by https://github.com/mathjax/MathJax-node/pull/317).

I'll double check later this week.

pkra commented 7 years ago

To clarify: by "removing this piece" I mean the MathJax block in the pageConfig; try it with

const pageConfig = {
    format: ["TeX"]
};

instead and it should work.

tuanmh commented 7 years ago

Thank you greatly for confirming @pkra.

pkra commented 7 years ago

Confirmed as an upstream issue (unfortunately not yet resolved). See https://github.com/mathjax/MathJax-node/issues/330

pkra commented 7 years ago

This will be fixed in the next mathjax-node release.