# Add mathjs to node red

**URL:** https://discourse.nodered.org/t/add-mathjs-to-node-red/20651
**Category:** General
**Created:** [20 January 2020 20:11 UTC](https://discourse.nodered.org/t/add-mathjs-to-node-red/20651 "2020-01-20T20:11:04Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![sondre](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@sondre](https://discourse.nodered.org/u/sondre)
#### Post date: [20 January 2020 20:11 UTC](https://discourse.nodered.org/t/add-mathjs-to-node-red/20651/1 "2020-01-20T20:11:04Z")

</div>

Hi  
Is it posible til add mathjs to node-red?  
I installed mathjs with npm and tried to add/enabled it in the settings.js fil

> Blockquote  
> Started Node-RED graphical event wiring tool.  
> Error loading settings file: /home/pi/.node-red/settings.js  
> ReferenceError: mathjs is not defined  
> at Object. (/home/pi/.node-red/settings.js:175:15)  
> at Module.\_compile (internal/modules/cjs/loader.js:778:30)  
> at Object.Module.\_extensions..js (internal/modules/cjs/loader.js:789:10)  
> at Module.load (internal/modules/cjs/loader.js:653:32)  
> at tryModuleLoad (internal/modules/cjs/loader.js:593:12)  
> at Function.Module.\_load (internal/modules/cjs/loader.js:585:3)  
> at Module.require (internal/modules/cjs/loader.js:692:17)  
> at require (internal/modules/cjs/helpers.js:25:18)  
> at Object. (/usr/lib/node\_modules/node-red/red.js:119:20)  
> at Module.\_compile (internal/modules/cjs/loader.js:778:30)

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [20 January 2020 20:25 UTC](https://discourse.nodered.org/t/add-mathjs-to-node-red/20651/2 "2020-01-20T20:25:23Z")

</div>

Hi @sondre

how did you install `mathjs`? What command did you run and what directory were you in when you ran it?

What have you then added to your settings.js file to load it?

---

<div class="post-metadata">

### Author: ![sondre](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@sondre](https://discourse.nodered.org/u/sondre)
#### Post date: [20 January 2020 21:36 UTC](https://discourse.nodered.org/t/add-mathjs-to-node-red/20651/3 "2020-01-20T21:36:43Z")

</div>

Installed in the folder for node-red

> Blockquote  
> pi@raspberrypi:~/.node-red $ npm install mathjs

Added this line to the settings file

> Blockquote  
> functionGlobalContext: {  
> mathjs:require(mathjs),

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [20 January 2020 21:56 UTC](https://discourse.nodered.org/t/add-mathjs-to-node-red/20651/4 "2020-01-20T21:56:34Z")

</div>

You have missed some quotes:

```auto
functionGlobalContext: {
     mathjs:require("mathjs"),

```

---

<div class="post-metadata">

### Author: ![sondre](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@sondre](https://discourse.nodered.org/u/sondre)
#### Post date: [20 January 2020 23:09 UTC](https://discourse.nodered.org/t/add-mathjs-to-node-red/20651/5 "2020-01-20T23:09:43Z")

</div>

Thank you for pointing out that error. It's working now 🙂
