Re: [mathjax-users] mathjax-node (convert mathML to SVG on node.js)

13 views
Skip to first unread message

Davide Cervone

unread,
Mar 13, 2024, 7:35:25 AMMar 13
to mathja...@googlegroups.com
The key portion of the error message is the line

Error: ENOENT: no such file or directory, open '/var/task/node_modules/mathjax/unpacked/extensions/toMathML.js']

which says that this file is not being found.  So you need to check that this file exists on your server.  It looks like not all the files have been installed there.

Davide


On Mar 10, 2024, at 5:55 AM, Pawel <pawel...@gmail.com> wrote:

Hello,
I am working on app which should convert mathML equations (with injected data from frontend) on backend (node.js).
It should work in steps (all steps in node.js):
1 - convert mathML to SVG (mahjax-node)
2 - convert SVG to PNG (sharp)
3 - add PNG to PDF (jsPDF)

On my local machine everything works like a charm i receive nice equations in PDF (checked with mathjax-node versions 2.1.1 and 1.3.0).
However, when i deploy my app to vercel.com i receive a lot of errors.

When i use mathjax-node 2.1.1 i receive:
e_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:82:17)
    at HTMLScriptElementImpl.dispatchEvent (/var/task/node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:30:27)
    at /var/task/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:42:17
    at Object.check (/var/task/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:76:11)
    at ReadStream.<anonymous> (/var/task/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:95:12)
    at ReadStream.wrappedEnqueued (/var/task/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:253:16)
    at ReadStream.emit (node:events:527:28) TypeError: Cannot read properties of undefined (reading 'resetGlyphs')
    at /var/task/node_modules/mathjax-node/lib/main.js:521:35
    at Function.execute (file:///var/task/node_modules/mathjax/unpacked/MathJax.js:243:26)
    at cb (file:///var/task/node_modules/mathjax/unpacked/MathJax.js:225:59)
    at Object.Execute (file:///var/task/node_modules/mathjax/unpacked/MathJax.js:426:36)
    at Object.ExecuteHooks (file:///var/task/node_modules/mathjax/unpacked/MathJax.js:604:31)
    at Function.execute (file:///var/task/node_modules/mathjax/unpacked/MathJax.js:243:26)
    at cb (file:///var/task/node_modules/mathjax/unpacked/MathJax.js:225:59)
    at Object.Execute (file:///var/task/node_modules/mathjax/unpacked/MathJax.js:426:36)
    at Object.Post (file:///var/task/node_modules/mathjax/unpacked/MathJax.js:537:37)
    at Function.execute (file:///var/task/node_modules/mathjax/unpacked/MathJax.js:243:26)
2022-07-09T20:00:40.850Z abf3e37a-e3a7-42b7-a130-2b62375b0b9e ERROR Error: Could not load script: "file:///var/task/node_modules/mathjax/unpacked/extensions/toMathML.js?V=2.7.9"
    at /var/task/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:44:23
    at Object.check (/var/task/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:76:11)
    at ReadStream.<anonymous> (/var/task/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:95:12)
    at ReadStream.wrappedEnqueued (/var/task/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:253:16)
    at ReadStream.emit (node:events:527:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) [Error: ENOENT: no such file or directory, open '/var/task/node_modules/mathjax/unpacked/extensions/toMathML.js'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/var/task/node_modules/mathjax/unpacked/extensions/toMathML.js'
}
2022-07-09T20:00:40.853Z abf3e37a-e3a7-42b7-a130-2b62375b0b9e ERROR File load error: file:///var/task/node_modules/mathjax/unpacked/jax/element/mml/jax.js
2022-07-09T20:00:40.854Z abf3e37a-e3a7-42b7-a130-2b62375b0b9e ERROR Error: Could not load script: "file:///var/task/node_modules/mathjax/unpacked/jax/element/mml/jax.js?V=2.7.9"
    at /var/task/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:44:23
    at Object.check (/var/task/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:76:11)
    at ReadStream.<anonymous> (/var/task/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:95:12)
    at ReadStream.wrappedEnqueued (/var/task/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:253:16)
    at ReadStream.emit (node:events:527:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) [Error: ENOENT: no such file or directory, open '/var/task/node_modules/mathjax/unpacked/jax/element/mml/jax.js'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/var/task/node_modules/mathjax/unpacked/jax/element/mml/jax.js'
}
2022-07-09T20:00:48.554Z abf3e37a-e3a7-42b7-a130-2b62375b0b9e Task timed out after 10.02 seconds


Due to errors i made a downgrade to mathjax-node 1.3.0 and i receive this errors:
File load error: file:///var/task/backend/node_modules/mathjax/unpacked/jax/input/TeX/config.js
File load error: file:///var/task/backend/node_modules/mathjax/unpacked/jax/input/MathML/config.js
File load error: file:///var/task/backend/node_modules/mathjax/unpacked/jax/input/AsciiMath/config.js
File load error: file:///var/task/backend/node_modules/mathjax/unpacked/jax/output/SVG/config.js
File load error: file:///var/task/backend/node_modules/mathjax/unpacked/jax/output/CommonHTML/config.js
File load error: file:///var/task/backend/node_modules/mathjax/unpacked/extensions/toMathML.js
Error: TypeError: Cannot read properties of undefined (reading 'resetGlyphs')
at /var/task/backend/node_modules/mathjax-node/lib/main.js:451:31
at Function.execute (file:///var/task/backend/node_modules/mathjax/unpacked/MathJax.js:243:26)
at cb (file:///var/task/backend/node_modules/mathjax/unpacked/MathJax.js:225:59)
at Object.Execute (file:///var/task/backend/node_modules/mathjax/unpacked/MathJax.js:426:36)
at Object.ExecuteHooks (file:///var/task/backend/node_modules/mathjax/unpacked/MathJax.js:604:31)
at Function.execute (file:///var/task/backend/node_modules/mathjax/unpacked/MathJax.js:243:26)
at cb (file:///var/task/backend/node_modules/mathjax/unpacked/MathJax.js:225:59)
at Object.Execute (file:///var/task/backend/node_modules/mathjax/unpacked/MathJax.js:426:36)
at Object.Post (file:///var/task/backend/node_modules/mathjax/unpacked/MathJax.js:537:37)
at Function.execute (file:///var/task/backend/node_modules/mathjax/unpacked/MathJax.js:243:26)


I have created a small repo which recreate this error:

Has anyone encountered such errors and found a solution?

I'm also wondering whether to use, mathjax@3 instead of mathjax-node (which is quite old) to transform mathML to SVG on node.js. However, I have a problem with how to go about it.

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/22fd8a8c-b454-4648-97ce-6a02a91a13cen%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages