How do I actually use this with npm?

1,305 views
Skip to first unread message

johann...@gmail.com

unread,
Apr 27, 2016, 5:51:04 AM4/27/16
to MathJax Users
Seriously, the documentation is very detailed on what to do when including the files with <script> and stuff.

But it gives absolutely ZERO info on how to use MathJax when you install it via npm.

The docs make it very clear that you need to configure MathJax before you actually load it. But give no hint at all how to actually achieve that in an npm setting.

And I'm not really in a mood for guessing games.

Peter Krautzberger

unread,
Apr 27, 2016, 7:17:32 AM4/27/16
to mathja...@googlegroups.com
Hi,

You might want to check out the User Group guidelines for some general advice on posting to the User Group.

But it gives absolutely ZERO info on how to use MathJax when you install it via npm.

There is no difference when it comes to configuring MathJax. The npm package for MathJax is primarily a convenience for developers who use npm to manage front-end assets. 

> But give no hint at all how to actually achieve that in an npm setting.

It's unclear what "in an npm setting" might refer to. If you're trying to use MathJax in a NodeJS application, then, as described in the documentation, you'll need to look at mathjax-node.

Regards,
Peter.


--
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.
For more options, visit https://groups.google.com/d/optout.

johann...@gmail.com

unread,
Apr 27, 2016, 7:30:22 AM4/27/16
to MathJax Users
I actually did check out those guidelines.

And "zero difference"?

I'm doing require Mathjax from 'Mathjax' on the client on a Meteor project in an ES6 setting. Any and all import statements need to go on top of the page. But the docs explicitly state that configuration needs to come before loading Mathjax.

What is the equivalent of

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
<script type="text/javascript" async src="path-to-mathjax/MathJax.js?config=TeX-AMS_CHTML"></script>

when using npm?

Peter Krautzberger

unread,
Apr 27, 2016, 7:40:37 AM4/27/16
to mathja...@googlegroups.com

I'm doing require Mathjax from 'Mathjax' on the client on a Meteor project in an ES6 setting. Any and all import statements need to go on top of the page. 

MathJax is not a CommonJS module so you cannot do this at this time. Again, the npm package is primarily a convenience for asset management.

You probably want to go to a general purpose forum like StackOverflow to get help with Meteor.

Regards,
Peter.

polarapps...@gmail.com

unread,
Apr 17, 2018, 9:37:40 AM4/17/18
to MathJax Users
Hey Peter,

it's been two years since the last update on this thread. 
Any new information on this? Can I use MathJax now as an npm module like require Mathjax from 'Mathjax'? At least I couldn't find any more info in the documentation so far.

– frederik 

Davide Cervone

unread,
Apr 22, 2018, 11:45:31 AM4/22/18
to mathja...@googlegroups.com
MathJax v2.x can't be use in this way, and is not likely to be able to be.  There is mathjax-node, which is a library that you can use to access MathJax's functionality, but it is a bit of a hack, and it may not be as well integrated into node as you would like.

We are in the process of developing MathJax v3.0, and that will work with ES6 and node much more readily.  This is currently in alpha testing, and you can see the current state at 


with some documentation on how to use it at


and more demos at


along with webpacked files that can be loaded into web pages.

Davide

Peter Krautzberger

unread,
Apr 24, 2018, 11:14:12 AM4/24/18
to mathja...@googlegroups.com
Hi Frederik,

I no longer work for MathJax so my responses are slow these days.

What Davide said is, of course, the best suggestion.

If you just need a copy of MathJax for a single-file distribution, you could try https://github.com/pkra/MathJax-single-file/, e.g., one of the builds or roll your own in a pre-build step.

Regards,
Peter.




To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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-users+unsubscribe@googlegroups.com.

kim gysen

unread,
Oct 12, 2022, 6:33:03 PM10/12/22
to MathJax Users
Very strange. Great library, great content... but packaging it into an npm module is not possible? Ok but it's a bit weird. Keep up the good work though. 

Op dinsdag 24 april 2018 om 17:14:12 UTC+2 schreef pe...@krautzource.com:

Davide Cervone

unread,
Oct 12, 2022, 7:12:50 PM10/12/22
to mathja...@googlegroups.com
The message you are responding to is four-and-a-half years old, and much has changed since then.  Version 2 was not designed with node.js in mind, and so it was not easy to use outside a browser.  The mathjax-node repository holds a version that can be used from node, but it is clunky, slow, and fragile.

Version 3 was redesigned from the ground up, and was developed to be able to be used in node as well as the browser.  There are two npm packages for it, mathjax and mathjax-full, depending on your needs.  You can see examples of using MathJax v3 in node in the MathJax-demos-node repository.

Davide


Reply all
Reply to author
Forward
0 new messages