Requiring mathjs

728 Views Asked by At

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 [email protected]. Please load "mathjs" or "mathjs/lib/cjs/index.js" instead.

1

There are 1 best solutions below

0
Eray Ismailov On

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'