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

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?

1 Like

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.

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.

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...

1 Like

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