Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • M MathJax
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 304
    • Issues 304
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 15
    • Merge requests 15
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • MathJax
  • MathJax
  • Issues
  • #2486
Closed
Open
Issue created Jul 30, 2020 by Administrator@rootContributor

"Cannot find module /es5/input/tex.js" error in Windows Node

Created by: curbengh

Issue Summary

I'm trying to integrate mathjax (tex => svg) into this node app (https://github.com/hexojs/hexo-math/pull/130). Unit test ran fine in GitHub Actions' Ubuntu and OSX environments but failed in Windows with MathJax(input/tex): Cannot find module '/es5/input/tex.js' error (log).

Affects Node 10, 12 & 14. Same issue in Travis.

Steps to Reproduce:

lib/mathjax.js

const { init } = require('mathjax');

module.exports = hexo => {
  return async function mathjaxFn(args, content) {
    if (this.mathjax === false) return content;

    const { options: globalCfg } = hexo.config.math.mathjax;
    const { mathjax: fmCfg } = this;
    const [jsonCfg] = args;
    const argsCfg = jsonCfg ? JSON.parse(jsonCfg) : false;
    let options = Object.assign({}, globalCfg);
    if (fmCfg) options = Object.assign({}, options, fmCfg);
    if (argsCfg) options = Object.assign({}, options, argsCfg);
    const { conversion, svg, tex } = options;

    const MathJax = await init({
      loader: {
        load: ['input/tex', 'output/svg']
      },
      tex,
      svg
    });

    const { startup, tex2svgPromise } = MathJax;
    const svgOut = await tex2svgPromise(content, conversion);

    return startup.adaptor.outerHTML(svgOut);
  };
};

Unit test test/index.js

    describe('mathjax', () => {
      const m = require('../lib/mathjax')(hexo).bind({});
      const content = '\\frac{1}{x^2-1}';
      const displayFalse = '<mjx-container class="MathJax" jax="SVG">';
      const displayTrue = '<mjx-container class="MathJax" jax="SVG" display="true">';

      it('default', async () => {
        const output = await m(args, content);

        output.startsWith(displayFalse).should.eql(true);
      });
    });

Technical details:

  • MathJax Version: 3.0.5
  • OS: Windows Server 2019
  • Nodejs: v10.21.0, v12.18.2, v14.5.0

Supporting information:

https://github.com/hexojs/hexo-math/pull/130

Configuration ./index.js

  mathjax: {
    options: {
      // https://docs.mathjax.org/en/latest/web/typeset.html#conversion-options
      conversion: {
        display: false
      },
      // https://docs.mathjax.org/en/latest/options/input/tex.html
      tex: {},
      // https://docs.mathjax.org/en/latest/options/output/svg.html
      svg: {}
    }
  }
Assignee
Assign to
Time tracking