Import math.js in node.js repl

Hi!
Is there a way to import math.js, available at cdnjs.com or local, to a node.js repl? If so, how do I do that?

Hey @nikodemus, welcome to the community!

You can do this, just follow these steps :

  1. Install math.js via npm :
    npm install mathjs
    
  2. The require it :
    const math = require('mathjs');
    
  3. And here is an example code I found :
    const matrix = math.matrix([[1, 2], [3, 4]]);
    const transpose = math.transpose(matrix);
    console.log(transpose);
    

Hope this works!

3 Likes

Works perfect, thanks!

1 Like

No problem, great to hear!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.