# Docs on "Loading additional modules" outdated?

**URL:** https://discourse.nodered.org/t/docs-on-loading-additional-modules-outdated/48112
**Category:** General
**Created:** [7 July 2021 06:21 UTC](https://discourse.nodered.org/t/docs-on-loading-additional-modules-outdated/48112 "2021-07-07T06:21:09Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![SewShulMeedeeUh](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@SewShulMeedeeUh](https://discourse.nodered.org/u/SewShulMeedeeUh)
#### Post date: [7 July 2021 06:21 UTC](https://discourse.nodered.org/t/docs-on-loading-additional-modules-outdated/48112/1 "2021-07-07T06:21:09Z")

</div>

Via here...  
[https://nodered.org/docs/user-guide/writing-functions#loading-additional-modules](https://nodered.org/docs/user-guide/writing-functions#loading-additional-modules)

> Modules loaded from your settings file must be installed in the same directory as the settings file. For most users that will be the default user directory - `~/.node-red`...

If I...  
`docker run --rm -it --entrypoint /bin/sh nodered/node-red:1.3.5-minimal`

Default/home directory is...

> /usr/src/node-red

Then ls -la (list all contents with details)...

> .ash\_history  
> node\_modules  
> package.json

Essentially, despite successfully including some contrib and other npm packages in my `package.json`, editing `settings.json` to reference them (successfully) there is **no** `~/.node_red` path.

Is this intended? Are the docs out of date? Is this some peculiarity of the docker version (any idea why)?

It seems like, rather than going the editing `settings.json` and then `global.get` route, it would be easier if importing libraries could be done [within the function UI](https://nodered.org/docs/user-guide/writing-functions#using-the-functionexternalmodules-option) (specifically, I am using [node-postgres](https://www.npmjs.com/package/pg)).

Essentially, as per node-red v1.3 (as per the [docs](https://nodered.org/docs/user-guide/writing-functions#using-the-functionexternalmodules-option)), has the workflow been simplified in that merely adding a library in `package.json` should allow referencing it in the function UI... negating the need to hand-edit the `settings.json` file?

---

<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: [7 July 2021 06:46 UTC](https://discourse.nodered.org/t/docs-on-loading-additional-modules-outdated/48112/2 "2021-07-07T06:46:18Z")

</div>

The docs you link to are for when you are running Node-RED locally.

The docker container uses `/data` as the Node-RED user directory as described here: [Running under Docker : Node-RED](https://nodered.org/docs/getting-started/docker#managing-user-data)

If you mount that externally, as described at the above link, you'll be able to edit the settings file to enable the external modules feature for the function node.

---

<div class="post-metadata">

### Author: ![SewShulMeedeeUh](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@SewShulMeedeeUh](https://discourse.nodered.org/u/SewShulMeedeeUh)
#### Post date: [7 July 2021 06:57 UTC](https://discourse.nodered.org/t/docs-on-loading-additional-modules-outdated/48112/3 "2021-07-07T06:57:48Z")

</div>

A couple of follow up questions (if I may)... why the disparity in design between "using Node-RED locally" vs using it in Docker (why wouldnt the docker implementation use the same design?) Is there something technically/systemically driving the difference?

So, if in the docker version, what would be the proper way to facilitate usage of referencing external modules via the function UI? Is that functionality hardwired to reference a `~/.node-red` vs the contents populated in the `/data` folder in the docker instance?

Does the function UI method still require editing `settings.js` to enable them via the `functionGlobalContext` before they can be referenced in the UI?

---

<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: [7 July 2021 07:03 UTC](https://discourse.nodered.org/t/docs-on-loading-additional-modules-outdated/48112/4 "2021-07-07T07:03:59Z")

</div>

> [@SewShulMeedeeUh](#):
>
> why the disparity in design between "using Node-RED locally" vs using it in Docker

A historical choice.

> [@SewShulMeedeeUh](#):
>
> what would be the proper way to facilitate usage of referencing external modules via the function UI? Is that functionality hardwired to reference a `~/.node-red` vs the contents populated in the `/data` folder in the docker instance?

Nothing is hardcoded to `~/.node-red`. It uses whatever the `userDir` property is set to (-u on the Node-RED command line). It defaults to `~/.node-red` if not set otherwise.

So as I said, of you mount `/data` externally as the docs describe, you can edit your settings file, npm install modules etc.

> [@SewShulMeedeeUh](#):
>
> Does the function UI method still require editing `settings.js` to enable them via the `functionGlobalContext` before they can be referenced in the UI?

The 1.3 release introduced the functionExternalModules` option: [Version 1.3 released : Node-RED](https://nodered.org/blog/2021/04/08/version-1-3-released#function-node-use-of-npm-modules)

Once enabled (it is currently disabled by default), this lets you manage what modules the function node uses.

---

<div class="post-metadata">

### Author: ![SewShulMeedeeUh](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@SewShulMeedeeUh](https://discourse.nodered.org/u/SewShulMeedeeUh)
#### Post date: [7 July 2021 07:09 UTC](https://discourse.nodered.org/t/docs-on-loading-additional-modules-outdated/48112/5 "2021-07-07T07:09:26Z")

</div>

> [@knolleary](#):
>
> Once enabled (it is currently disabled by default), this lets you manage what modules the function node uses.

After editing `settings.json`, or only after merely including them in the `package.json`?

Perhaps I should've been more clear in mentioning, if I can avoid having to mess with `settings.json` and simplify my docker build, I am all for it 😁

---

<div class="post-metadata">

### Author: ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)
#### Post date: [7 July 2021 07:09 UTC](https://discourse.nodered.org/t/docs-on-loading-additional-modules-outdated/48112/6 "2021-07-07T07:09:31Z")

</div>

> > [@SewShulMeedeeUh](#):
> >
> > why the disparity in design between "using Node-RED locally" vs using it in Docker
> 
> A historical choice.

Also `/data` is expected convention for where docker containers should keep this sort of data

---

<div class="post-metadata">

### Author: ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)
#### Post date: [7 July 2021 07:12 UTC](https://discourse.nodered.org/t/docs-on-loading-additional-modules-outdated/48112/7 "2021-07-07T07:12:57Z")

</div>

You are going to need to update `settings.js` to enable the feature in the function node, but you shouldn't need to add the modules to the functionGlobalContext if using the new function node capability.

---

<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: [7 July 2021 07:17 UTC](https://discourse.nodered.org/t/docs-on-loading-additional-modules-outdated/48112/8 "2021-07-07T07:17:12Z")

</div>

The new external modules feature does _not_ install the modules under the existing package.json. They are installed in a subdirectory with its own package.json file. This isn't an ideal situation, but it is what it is today. We may revisit it in a future release.

I suggest you enable the feature.in your settings file (which you must do), then use the editor to add some modules to a function node (as described in the link I sent). Then have a look to see where the modules got installed.

---

<div class="post-metadata">

### Author: ![SewShulMeedeeUh](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@SewShulMeedeeUh](https://discourse.nodered.org/u/SewShulMeedeeUh)
#### Post date: [7 July 2021 07:17 UTC](https://discourse.nodered.org/t/docs-on-loading-additional-modules-outdated/48112/9 "2021-07-07T07:17:23Z")

</div>

> [@hardillb](#):
>
> You are going to need to update `settings.js` to enable the feature in the function node

Ah, excellent point/catch/clarification... as knolleary mentioned, "once enabled (disabled by default)" and you helped drive the point, the `settings.json` will have to be edited anyway (at least once) to override the default behavior.

---

<div class="post-metadata">

### Author: ![SewShulMeedeeUh](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@SewShulMeedeeUh](https://discourse.nodered.org/u/SewShulMeedeeUh)
#### Post date: [7 July 2021 07:22 UTC](https://discourse.nodered.org/t/docs-on-loading-additional-modules-outdated/48112/10 "2021-07-07T07:22:04Z")

</div>

Thank you both for the answers/clarifications! I'm not sure which to mark as "solution" (and how important it not being marked might be, in this community)

---

<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: [5 September 2021 07:22 UTC](https://discourse.nodered.org/t/docs-on-loading-additional-modules-outdated/48112/11 "2021-09-05T07:22:07Z")

</div>

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