# Can we install a module and a storage module in node-red user directory

**URL:** <https://discourse.nodered.org/t/can-we-install-a-module-and-a-storage-module-in-node-red-user-directory/93873>\
**Category:** Developing Nodes\
**Created:** [12 December 2024 10:47 UTC](https://discourse.nodered.org/t/can-we-install-a-module-and-a-storage-module-in-node-red-user-directory/93873 "2024-12-12T10:47:52Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![RomainPoltronieri](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/romainpoltronieri/32/97155_2.png) [@RomainPoltronieri](https://discourse.nodered.org/u/RomainPoltronieri)\
**Post date:** [12 December 2024 10:47 UTC](https://discourse.nodered.org/t/can-we-install-a-module-and-a-storage-module-in-node-red-user-directory/93873/1 "2024-12-12T10:47:52Z")

</div>

Hello,

I have an issue with storage plugin and node module local installation.

I have written:

- a node-red-contrib-postgres-storage module meant to be used as a storageModule
- a node-red-contrib-flow-metadata module that contains a Node-RED node

Both are still in development, so I'd like to be able to install both locally.

My issue is:

- If I install only node-red-contrib-flow-metadata in ~/.node-red this way:

C:\Users\Admin.node-red\> npm install node-red-contrib-flow-metadata

Then it works as expected, i.e. the new node is available in the palette, and node-red-contrib-flow-metadata is displayed underneath node-red in User Settings \> Palette \> Nodes

- if I install only node-red-contrib-postgres-storage in ~/.node-red this way:

C:\Users\Admin.node-red\> npm install C:\workspace\node-red-contrib-postgres-storage --install-links

Then it works as expected, i.e. if I add this line to C:\Users\Admin.node-red\settings.js:

storageModule: require("node-red-contrib-postgres-storage"),

Then Node-RED uses the storage module as expected.

- But if I install both node-red-contrib-postgres-storage and node-red-contrib-flow-metadata in ~/.node-red, the storage still works, but the new node does not show up in the palette anymore, and node-red-contrib-flow-metadata is not displayed in User Settings \> Palette \> Nodes anymore

If I uninstall node-red-contrib-postgres-storage from ~/.node-red, then node-red-contrib-flow-metadata works again.

Has anyone had this issue before ? Should I raise an issue on the node-red GitHub ?

Thanks,

Romain

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [12 December 2024 19:51 UTC](https://discourse.nodered.org/t/can-we-install-a-module-and-a-storage-module-in-node-red-user-directory/93873/2 "2024-12-12T19:51:14Z")

</div>

As these are both nodes written by you... is there a chance you have duplicated a bunch of scaffolding code into both, such that they have duplicate names/functions/properties , and are clashing with each other ?

---

<div class="post-metadata">

**Author:** ![RomainPoltronieri](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/romainpoltronieri/32/97155_2.png) [@RomainPoltronieri](https://discourse.nodered.org/u/RomainPoltronieri)\
**Post date:** [13 December 2024 08:42 UTC](https://discourse.nodered.org/t/can-we-install-a-module-and-a-storage-module-in-node-red-user-directory/93873/3 "2024-12-13T08:42:29Z")

</div>

Thanks for your suggestion, that's a good idea. However I've double checked, and everything seems different. I haven't created one from the other, or even both from the same template (I created the storage module from another one I found on the Node-RED library, and I created the node module from the "first node" template on the Node-RED web site ( [Creating your first node : Node-RED](https://nodered.org/docs/creating-nodes/first-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:** [13 December 2024 10:01 UTC](https://discourse.nodered.org/t/can-we-install-a-module-and-a-storage-module-in-node-red-user-directory/93873/4 "2024-12-13T10:01:08Z")

</div>

After you run the `npm install` command each time, check the contents of `~/.node-red/package.json`. Check your modules are being added to the dependencies section of that file.

With both installed:

- do you get any error messages in the node-red log when you start node-red?
- check the contents of `~/.node-red/.config.nodes.json` - search it for any mention of your `contrib-flow-metadata` node. Is it there? If so, does it have an `error` property?

---

<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:** [13 December 2024 14:38 UTC](https://discourse.nodered.org/t/can-we-install-a-module-and-a-storage-module-in-node-red-user-directory/93873/5 "2024-12-13T14:38:12Z")

</div>

Also are your nodes somewhere we can look at them, e.g. github?

---

<div class="post-metadata">

**Author:** ![RomainPoltronieri](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/romainpoltronieri/32/97155_2.png) [@RomainPoltronieri](https://discourse.nodered.org/u/RomainPoltronieri)\
**Post date:** [13 December 2024 15:16 UTC](https://discourse.nodered.org/t/can-we-install-a-module-and-a-storage-module-in-node-red-user-directory/93873/6 "2024-12-13T15:16:52Z")

</div>

Thanks for your suggestion.  
Starting from a fresh Node-RED install, ~/.node-red/package.json is clean:

```auto
{
    "name": "node-red-project",
    "description": "A Node-RED Project",
    "version": "0.0.1",
    "private": true
}

```

If I install my node module:

```auto
PS C:\Users\Admin\.node-red\node_modules> npm install C:\workspace\node-red-contrib-flow-metadata --install-links

added 1 package, and audited 2 packages in 4s

found 0 vulnerabilities

```

package.json now contains the dependency:

```auto
    "dependencies": {
        "node-red-contrib-flow-metadata": "file:../../../workspace/node-red-contrib-flow-metadata"
    }

```

Node-RED starts with no error in its output, and I can see the new node in the palette.

If I then install the storage module:

```auto
PS C:\Users\Admin\.node-red\node_modules> npm install C:\workspace\node-red-contrib-postgres-storage --install-links

added 16 packages, and audited 18 packages in 8s

found 0 vulnerabilities

```

The dependency is added in package.json:

```auto
    "dependencies": {
        "node-red-contrib-flow-metadata": "file:../../../workspace/node-red-contrib-flow-metadata",
        "node-red-contrib-postgres-storage": "file:../../../workspace/node-red-contrib-postgres-storage"
    }

```

Node-RED starts with no error in its output, the storage plugin works as expected, but I cannot see my new node any longer.

There is indeed a mention of the metadata module in ~/.node-red/.config.nodes.json, but no error:

```auto
    "node-red-contrib-flow-metadata": {
        "name": "node-red-contrib-flow-metadata",
        "version": "0.0.1",
        "local": true,
        "user": true,
        "nodes": {
            "metadata-edit": {
                "name": "metadata-edit",
                "types": [
                    "metadata-edit"
                ],
                "enabled": true,
                "local": true,
                "user": false,
                "module": "node-red-contrib-flow-metadata",
                "file": "\\Users\\Admin\\.node-red\\node_modules\\node-red-contrib-flow-metadata\\metadata-edit.js"
            }
        }
    }

```

Note that if I uninstall node-red-contrib-flow-metadata from ~/.node-red, and install it there instead:

```auto
C:\Users\Admin\AppData\Roaming\npm> npm install C:\workspace\node-red-contrib-flow-metadata

added 1 package

```

Then it all works fine - the storage plugin works as expected, and I can also see the new node brought by the node-red-contrib-flow-metadata module.

---

<div class="post-metadata">

**Author:** ![RomainPoltronieri](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/romainpoltronieri/32/97155_2.png) [@RomainPoltronieri](https://discourse.nodered.org/u/RomainPoltronieri)\
**Post date:** [13 December 2024 15:29 UTC](https://discourse.nodered.org/t/can-we-install-a-module-and-a-storage-module-in-node-red-user-directory/93873/7 "2024-12-13T15:29:05Z")

</div>

I'm not sure that is something I can do, as the modules are owned by the company I work for. Regarding the module that contains a node (contrib-flow-metadata), I was having this issue even when it was as simple as the node-red-contrib-example-lower-case from the Node-RED tutorial ( [Creating your first node : Node-RED](https://nodered.org/docs/creating-nodes/first-node)). The storage module is very similar to [gingerhelp/node-red-contrib-mysql-storage-plugin: Node Red MySQL Storage Plugin](https://github.com/gingerhelp/node-red-contrib-mysql-storage-plugin).

---

<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:** [13 December 2024 15:44 UTC](https://discourse.nodered.org/t/can-we-install-a-module-and-a-storage-module-in-node-red-user-directory/93873/8 "2024-12-13T15:44:28Z")

</div>

OK, can you share just the `package.json` files from them both. I'm mainly interested in if the storage module has a `node-red` section/

Also while you've said there are no errors in the startup log, could you please post it.

---

<div class="post-metadata">

**Author:** ![RomainPoltronieri](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/romainpoltronieri/32/97155_2.png) [@RomainPoltronieri](https://discourse.nodered.org/u/RomainPoltronieri)\
**Post date:** [13 December 2024 15:59 UTC](https://discourse.nodered.org/t/can-we-install-a-module-and-a-storage-module-in-node-red-user-directory/93873/9 "2024-12-13T15:59:14Z")

</div>

Sure:

- the storage module:

```auto
{
  "name": "node-red-contrib-postgres-storage",
  "version": "0.0.1",
  "description": "Node-RED Storage Plugin For Postgres",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "node-red",
    "postgres"
  ],
  "bugs": {
    "url": ""
  },
  "dependencies": {
    "pg": "^8.13.1",
    "when": "3.7.8"
  },
  "devDependencies": {
    "eslint": "^6.8.0",
    "eslint-config-node": "^4.0.0",
    "eslint-config-prettier": "^4.1.0",
    "eslint-plugin-import": "^2.20.1",
    "eslint-plugin-node": "^11.0.0",
    "eslint-plugin-prettier": "^3.0.1",
    "minimist": ">=1.2.2",
    "prettier": "^1.17.0"
  }
}

```

- the node module:

```auto
{
  "name": "node-red-contrib-flow-metadata",
  "version": "0.0.1",
  "description": "This node module contains nodes that offer an interface to a flow meta-data.",
  "main": "metadata-edit.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "node-red" : {
    "nodes": {
      "metadata-edit": "metadata-edit.js"
    }
  }
}

```

The startup log:

```auto
13 Dec 16:19:40 - [stor] Initializing storage module
13 Dec 16:19:40 - [stor] Getting settings
13 Dec 16:19:40 - [info] 

Welcome to Node-RED
===================

13 Dec 16:19:40 - [info] Node-RED version: v4.0.5
13 Dec 16:19:40 - [info] Node.js version: v22.11.0
13 Dec 16:19:40 - [info] Windows_NT 10.0.17763 x64 LE
13 Dec 16:19:42 - [info] Loading palette nodes
13 Dec 16:19:45 - [stor] Saving settings
13 Dec 16:19:45 - [info] Settings file : C:\Users\Admin\.node-red\settings.js
13 Dec 16:19:45 - [info] Context store : 'default' [module=memory]
13 Dec 16:19:45 - [stor] Getting flows
13 Dec 16:19:45 - [stor] Getting credentials
13 Dec 16:19:45 - [warn] 

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

13 Dec 16:19:45 - [info] Server now running at http://127.0.0.1:1880/
13 Dec 16:19:45 - [info] Starting flows
13 Dec 16:19:45 - [info] Started flows
13 Dec 16:19:45 - [stor] Getting sessions

```

(I have added the [stor] logs in the storage plugin)

---

<div class="post-metadata">

**Author:** ![RomainPoltronieri](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/romainpoltronieri/32/97155_2.png) [@RomainPoltronieri](https://discourse.nodered.org/u/RomainPoltronieri)\
**Post date:** [17 December 2024 08:53 UTC](https://discourse.nodered.org/t/can-we-install-a-module-and-a-storage-module-in-node-red-user-directory/93873/10 "2024-12-17T08:53:50Z")

</div>

I have checked and I confirm that I am having this issue even with a node module as simple as the lower-case example from the "Creating your first node" section of the Node-RED website.

That node module is as simple as these three files:

- lower-case.html:

```auto
<script type="text/javascript">
    RED.nodes.registerType('lower-case',{
        category: 'function',
        color: '#a6bbcf',
        defaults: {
            name: {value:""}
        },
        inputs: 1,
        outputs: 1,
        icon: "file.svg",
        label: function() {
            return this.name||"lower-case";
        }
    });
</script>

<script type="text/html" data-template-name="lower-case">
    <div class="form-row">
        <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
        <input type="text" id="node-input-name" placeholder="Name">
    </div>
</script>

<script type="text/html" data-help-name="lower-case">
    <p>A simple node that converts the message payloads into all lower-case characters</p>
</script>

```

- lower-case.js

```auto
module.exports = function(RED) {
    function LowerCaseNode(config) {
        RED.nodes.createNode(this,config);
        var node = this;
        node.on('input', function(msg) {
            msg.payload = msg.payload.toLowerCase();
            node.send(msg);
        });
    }
    RED.nodes.registerType("lower-case",LowerCaseNode);
}

```

- package.json:

```auto
{
  "name": "node-red-contrib-example-lower-case",
  "version": "1.0.0",
  "main": "lower-case.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "description": "",
  "node-red" : {
	"nodes": {
		"lower-case": "lower-case.js"
	}
  }
}

```

My storage plugin is pretty simple as well:

- package.json:

```auto
{
  "name": "node-red-contrib-postgres-storage",
  "version": "0.0.1",
  "description": "Node-RED Storage Plugin For Postgres",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "node-red",
    "postgres"
  ],
  "dependencies": {
    "pg": "^8.13.1",
    "when": "3.7.8"
  }
}

```

- index.js:

```auto
const when = require('when');
const Promise = when.promise;
const {
    Pool
} = require('pg');

const storageModule = {
...
// implementation of init, getFlows, saveFlows...
...

};

module.exports = storageModule;

```

---

<div class="post-metadata">

**Author:** ![Sullivan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sullivan/32/104425_2.png) [@Sullivan](https://discourse.nodered.org/u/Sullivan)\
**Post date:** [7 January 2025 12:28 UTC](https://discourse.nodered.org/t/can-we-install-a-module-and-a-storage-module-in-node-red-user-directory/93873/11 "2025-01-07T12:28:28Z")

</div>

Hello @RomainPoltronieri,

There is no duplicate name of other data between your two nodes.

Maybe your issue is related to the way you install your custom modules.  
You install them with `npm install c:/path/to/myModule --install-links`

In fact when i use `--install-links` i got some issue with the command `npm ls` saying `invalid: "..\..\path\to\myModule" from the root project`

I think that the issue might disapear if you push your custom nodes/modules in your artifactory but i am no expert.

---

<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:** [8 March 2025 12:29 UTC](https://discourse.nodered.org/t/can-we-install-a-module-and-a-storage-module-in-node-red-user-directory/93873/12 "2025-03-08T12:29:20Z")

</div>

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