# Javascript to Function node. Lost, very lost... :/

**URL:** <https://discourse.nodered.org/t/javascript-to-function-node-lost-very-lost/82036>\
**Category:** General\
**Created:** [14 October 2023 21:15 UTC](https://discourse.nodered.org/t/javascript-to-function-node-lost-very-lost/82036 "2023-10-14T21:15:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamadite](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tamadite/32/71047_2.png) [@Tamadite](https://discourse.nodered.org/u/Tamadite)\
**Post date:** [14 October 2023 21:15 UTC](https://discourse.nodered.org/t/javascript-to-function-node-lost-very-lost/82036/1 "2023-10-14T21:15:03Z")

</div>

I found this JS parser:

> **[nmea-0183](https://www.npmjs.com/package/nmea-0183?activeTab=readme)**
>
> an NMEA-0183 parser/encoder library, cloned from David Howard. Latest version: 0.0.7, last published: 10 years ago. Start using nmea-0183 in your project by running \`npm i nmea-0183\`. There are 2 other projects in the npm registry using nmea-0183.

The code takes an ASCII string as input, parses it and returns a JSON object.

The `lib` folder contains multiple js files and the `codes` sub-folder again multiple js files in it. I have no idea how to set all this into the `Function` node.

I guess the `On Message` property could be something like this, but what about the rest of the code/files?

```auto
var nmea = require('nmea');

return nmea.parse(msg.payload);

```

Any hint is appreciated.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [14 October 2023 21:28 UTC](https://discourse.nodered.org/t/javascript-to-function-node-lost-very-lost/82036/2 "2023-10-14T21:28:27Z")

</div>

Hi @Tamadite,

If you're asking on how to use external modules in `function` nodes, please see my response here:

> [@Using npm module](https://discourse.nodered.org/t/using-npm-module/81977/2):
>
> Welcome to the forums @Greg50100, It may be worth searching for a Node that has already wrapped this in a Node RED Node, search here : [https://flows.nodered.org](https://flows.nodered.org) If not, it may still be possible, but its going to require some setup. Ensure your installation allows to use 3rd party modules in Function nodes. You do this by enabling a setting in settings.js line 455. functionExternalModules: true, [Screenshot 2023-10-12 at 17.55.43] settings.js is usually in your Node Red user directory …

---

<div class="post-metadata">

**Author:** ![Tamadite](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tamadite/32/71047_2.png) [@Tamadite](https://discourse.nodered.org/u/Tamadite)\
**Post date:** [15 October 2023 08:09 UTC](https://discourse.nodered.org/t/javascript-to-function-node-lost-very-lost/82036/3 "2023-10-15T08:09:49Z")

</div>

Thank you so much @marcus-j-davies for your reply. It has definitely put me on the right track.  
**TL;DR** : search for "npm & node-red" or in the "node-red library".

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [29 October 2023 08:10 UTC](https://discourse.nodered.org/t/javascript-to-function-node-lost-very-lost/82036/4 "2023-10-29T08:10:09Z")

</div>

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