# Node and plugin in same package.json

**URL:** <https://discourse.nodered.org/t/node-and-plugin-in-same-package-json/70766>\
**Category:** Developing Nodes\
**Created:** [17 November 2022 11:49 UTC](https://discourse.nodered.org/t/node-and-plugin-in-same-package-json/70766 "2022-11-17T11:49:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alevher](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alevher/32/65952_2.png) [@alevher](https://discourse.nodered.org/u/alevher)\
**Post date:** [17 November 2022 11:49 UTC](https://discourse.nodered.org/t/node-and-plugin-in-same-package-json/70766/1 "2022-11-17T11:49:58Z")

</div>

Hello everyone, i'm trying to prepare the package for my own set of nodes and i've encountered a problem.  
I have a plugin node and various other nodes and i want them to be installed in a single package but this keeps returning me an error if the plugins and node sections are together.

Basically this is my package.json:

```auto
{
  "name": "@sss/node-red-sss-dataManipulation",
  "version": "1.0.0",
  "description": "",
  "dependencies": {
		"axios": "^0.27.2",
		"crypto": "^1.0.1",
		"node-rsa": "^1.1.1",
		"rsa-pem-from-mod-exp": "^0.8.4",
		"utf8": "^3.0.0",
		"uuid": "^9.0.0",
		"mysql2": "^2.3.3",
        "pg": "^8.8.0",
		"alasql": "^1.7.3",
		"xlsx": "https://cdn.sheetjs.com/xlsx-0.18.10/xlsx-0.18.10.tgz",
		"sss-server": "file:./sss_server"
	},
  "node-red": {
    "nodes": {
      "addcolumns": "sss_add_columns/addcolumns.js",
	  "create-view": "sss_create_view/create-view.js",
  	  "csv2array": "sss_csv2array/sss-csv2array.js",
	  "db-hub": "sss_db_hub/db-hub.js",
	  "filter": "sss_filter/sss-filter.js",
	  "get-view-values": "sss_get_view_values/get-view-values.js",
	  "joinmatrix": "sss_join_matrix/joinmatrix.js",
	  "merge-messages": "sss_merge_messages/merge-messages.js",
	  "register-notification": "sss_register_notification/register-notification.js",
	  "renamelabels": "sss_rename_labels/renamelabels.js",
	  "sss-server": "sss_server/sss-server.js",
	  "update-view": "sss_update_view/update-view.js",
	  "sss-user": "sss_user/sss-user.js",
	  "xlsx2array": "sss_xlsx2array/sss_xlsx2Array.js"

    },
    "plugins": {
	  "sss-api": "sss_api/sss-api.js"
        }
  },
  "author": "DocSpace",
  "license": "ISC"
}

```

this does not work giving a similar exception:

TypeError: Cannot read properties of undefined (reading 'forEach')  
at Object.addModule (/usr/src/node-red/node\_modules/@node-red/registry/lib/registry.js:195:27)  
at /usr/src/node-red/node\_modules/@node-red/registry/lib/loader.js:138:34

Is there a way to fix this?  
Strangely, if i put my plugin node inside the nodes section everything will work except for a warning displayed at the start of nodered:

```auto
[warn] [@sss/node-red-sss-dataManipulation/sss-api] TypeError: Cannot read properties of undefined (reading 'plugins') 

```

I came across someone with the same problem : [How do Node-RED plugins work?](https://discourse.nodered.org/t/how-do-node-red-plugins-work/60890)

Is it fixable?

Thanks in advance

---

<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:** [17 November 2022 11:58 UTC](https://discourse.nodered.org/t/node-and-plugin-in-same-package-json/70766/2 "2022-11-17T11:58:47Z")

</div>

This may simply be a bug in Node-RED around how it handles modules that have both plugins and nodes in.

I know that's something I tested when we introduced plugins, but I cannot immediately point to an example module that does this today.

I think we need to investigate a bit more closely.

Depending on what you have in the plugin code, a working could be to list it in the `nodes` section... but again, you'd need to test that carefully to make sure it behaved as you wanted.

---

<div class="post-metadata">

**Author:** ![alevher](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alevher/32/65952_2.png) [@alevher](https://discourse.nodered.org/u/alevher)\
**Post date:** [17 November 2022 12:59 UTC](https://discourse.nodered.org/t/node-and-plugin-in-same-package-json/70766/3 "2022-11-17T12:59:16Z")

</div>

Ok, i'll check for good, thanks a lot

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [17 November 2022 17:21 UTC](https://discourse.nodered.org/t/node-and-plugin-in-same-package-json/70766/4 "2022-11-17T17:21:26Z")

</div>

As per my reply in the other thread, looks like you've hit this known issue: [Race condition when loading module with both Plugin and Nodes · Issue #3523 · node-red/node-red (github.com)](https://github.com/node-red/node-red/issues/3523)

---

<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:** [16 January 2023 17:21 UTC](https://discourse.nodered.org/t/node-and-plugin-in-same-package-json/70766/5 "2023-01-16T17:21:42Z")

</div>

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