1

I try to include the mathjs library into my project for the atan2(). When i try to include the folder that i installed using npm install @types/mathjs by var Math = require('mathjs/main/es5/index'); it throws an error that it is moved and i have to include mathjs or mathjs/lib/cjs/index.js instead. This however does not work as well. So how do i include the mathjs library?

The file "mathjs/main/es5/index.js" has been moved since mathjs@8.0.0. Please load "mathjs" or "mathjs/lib/cjs/index.js" instead.

Meng
  • 191
  • 9
  • I don't know the answer to what you've asked, but [vanilla JS has an `atan2` function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2). –  Apr 12 '21 at 13:18
  • try const Math = require('mathjs'); – Pawan Sharma Apr 12 '21 at 13:19
  • I tried const Math = require('mathjs'); did not work, For Nodejs v12.13.1 and Javascript (V8) 7.7.299.13-node.16 it returns a ReferenceError: atan2 is not defined – Meng Apr 12 '21 at 13:32

1 Answers1

0

What you have installed are the typings only you need the package itself that @types/mathjs depends to as well.

npm i mathjs
npm i -D @types/mathjs

then you can import from 'mathjs' like so

import { max, pi, acos } from 'mathjs'
Eray Ismailov
  • 305
  • 3
  • 8