Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot resolve 'mathjs/number'

Tags:

mathjs

I am using Math.js to parse and evaluate a mathematical expression, and am following the example at https://mathjs.org/docs/custom_bundling.html#numbers-only as I only need basic number support. "mathjs": "^8.1.1", is listed in my package.json dependencies.

When I run the example code below, I get Module not found: Error: Can't resolve 'mathjs/number':

// use light-weight, numbers only implementations of functions
import { create, all } from 'mathjs/number'

const math = create(all)
like image 501
Erich Avatar asked Oct 15 '25 01:10

Erich


1 Answers

Looks like maybe the documentation hasn't caught up. I was able to get this working by changing the line

import { create, all } from 'mathjs/number';

to

import { create, all } from 'mathjs/lib/esm/number';
like image 164
Erich Avatar answered Oct 18 '25 08:10

Erich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!