Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many demos fail to run on Node version 21 with "Function.prototype.apply was called on undefined" errors #59

Closed
ddribin opened this issue Feb 29, 2024 · 8 comments
Labels
Accepted Issue has been reproduced by MathJax team

Comments

@ddribin
Copy link

ddribin commented Feb 29, 2024

I am trying to use component/tex2svg and it fails with this error using Node v21.6.2. However it works with Node v20.11.1. I am on a macOS Sonoma 14.3 with both version of node installed via Homebrew. Also note that the demos in direct/ work on Node v21.6.2, but the ones in component/ and simple/ do not.

Here's the truncated error:

> /opt/homebrew/opt/node@21/bin/node -r esm ./tex2svg 'y = mx + b'
/Users/dave/src/MathJax-demos-node/node_modules/esm/esm.js:1
const __global__ = this; <... full-text-in-gist ... >


[/Users/dave/src/MathJax-demos-node/node_modules/cliui/build/index.cjs:1
TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function]

Node.js v21.6.2

The full error is big, so I put it in a Gist: https://gist.github.com/ddribin/8d1bf990f8edd87cdb14cf705b03b020

@ddribin ddribin changed the title Many demos fail with "Function.prototype.apply" on Node version 21 Many demos fail (e.g. component/tex2svg) with "Function.prototype.apply" on Node version 21 Feb 29, 2024
@ddribin ddribin changed the title Many demos fail (e.g. component/tex2svg) with "Function.prototype.apply" on Node version 21 Many demos fail to run on Node version 21 with "Function.prototype.apply was called on undefined" errors Feb 29, 2024
@ddribin
Copy link
Author

ddribin commented Feb 29, 2024

@dpvc
Copy link
Member

dpvc commented Feb 29, 2024

As you have determined, the issue is with the esm library, which is no longer being developed or supported. Fortunately, MathJax only needs it if you are running from the component source files. So if you use

/opt/homebrew/opt/node@21/bin/node tex2svg --dist 'y = mx + b'

that should work for you.

@dpvc dpvc added the Accepted Issue has been reproduced by MathJax team label Feb 29, 2024
@dpvc
Copy link
Member

dpvc commented Feb 29, 2024

PS, version 4 (now out in beta) does not have any dependency on esm, so in the future, this will not be a problem.

@ddribin
Copy link
Author

ddribin commented Mar 1, 2024

Thanks for the response! Yes, --dist works, even with Node v21.6.2. And good news about v4.

@ddribin
Copy link
Author

ddribin commented Mar 1, 2024

And thank you for MathJax! It is pretty great. ;-)

@dpvc
Copy link
Member

dpvc commented Mar 1, 2024

Glad that worked, and thanks for the kind words!

@ddribin
Copy link
Author

ddribin commented Mar 7, 2024

Quick followup here. Node v21.7.0 was just released and it fixes the issue.

> node --version
v21.7.0

Gonna close this, since it is no longer an issue. Thanks for the help!

@ddribin ddribin closed this as completed Mar 7, 2024
@dpvc
Copy link
Member

dpvc commented Mar 7, 2024

Thanks for the additional information. I ran into it in another situation myself, so glad to see that 21.7.0 resolves that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team
Projects
None yet
Development

No branches or pull requests

2 participants