# Accessing moment.js in a function node (v1.1.0)

**URL:** https://discourse.nodered.org/t/accessing-moment-js-in-a-function-node-v1-1-0/29500
**Category:** General
**Created:** [4 July 2020 13:58 UTC](https://discourse.nodered.org/t/accessing-moment-js-in-a-function-node-v1-1-0/29500 "2020-07-04T13:58:26Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [4 July 2020 13:58 UTC](https://discourse.nodered.org/t/accessing-moment-js-in-a-function-node-v1-1-0/29500/1 "2020-07-04T13:58:26Z")

</div>

Adding `$moment("2020-07-01T13:00:52.345Z").format('LLLL')` as a jsonata expression in a change node, gives you `Wednesday, July 1, 2020 1:00 PM` - very nice.

But including `msg.payload = moment("2020-07-01T13:00:52.345Z").format('LLLL');` in a function node, gives you `"ReferenceError: moment is not defined (line 1, col 1)"` which seems a bit inconsistent.

How do you access `moment` in a function node?

---

<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: [4 July 2020 14:21 UTC](https://discourse.nodered.org/t/accessing-moment-js-in-a-function-node-v1-1-0/29500/2 "2020-07-04T14:21:09Z")

</div>

You can't access moment in the function node.

As mentioned in the beta forum posts and the release blog post. It's something to consider for the future.

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [4 July 2020 18:39 UTC](https://discourse.nodered.org/t/accessing-moment-js-in-a-function-node-v1-1-0/29500/3 "2020-07-04T18:39:02Z")

</div>

> [@knolleary](#):
>
> You can't access moment in the function node

Sorry, don't know how I missed that in the blog post, I guess at the time of reading I didn't think I'd need moment.js, and skipped over it.

It would be good to have access to `moment` in the function node, as it's very limiting being restricted to change nodes (especially if we are not familiar with the dark arts (jsonata)).  
However, one step at a time and hopefully it may be added in the future.

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [4 July 2020 19:18 UTC](https://discourse.nodered.org/t/accessing-moment-js-in-a-function-node-v1-1-0/29500/4 "2020-07-04T19:18:18Z")

</div>

Agree but meanwhile just use `settings.js` and include it in the global context. Personally I would also like to have `lodash` out of the box but it's a slippery slope I guess...

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [2 September 2020 19:18 UTC](https://discourse.nodered.org/t/accessing-moment-js-in-a-function-node-v1-1-0/29500/5 "2020-09-02T19:18:23Z")

</div>

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