Hello Everyone!
I have some questions while i'm preparing myself to publish my own set of nodes.
Basically i developed the nodes indipendently with its own package.json and here comes the first question:
-Is it possible to publish an npm package with indipendent package.json? Do i have to do a big package.json with all the nodes and dependencies or can i keep the indipendent ones ( i'd like them to be installed altoghether and not singularly). If i can keep the indipendent ones, how can i make them install together in a single npm package?
Basically like this:
โโโ LICENSE
โโโ README.md
โโโ examples
โ โโโ example-1.json
โ โโโ example-2.json
โโโ node1
โโโ icons
โ โโโ my-icon.svg
โโโ sample.html
โโโ package.json
โโโ sample.js
โโโ node2
โโโ icons
โ โโโ my-icon.svg
โโโ sample.html
โโโ package.json
โโโ sample.js
And here comes the second question, i've then amde a big package.json with all the nodes and dependencies but when i try to install it from the .node-red folder it doesn't install the dependencies in the package.json and i have to install them by going in the package folder and do npm install.
Is there a way to fix this?
Package.json is composed like this:
{
"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",
"sss-api": "sss_api/sss-api.js"
}
},
"author": "DocSpace",
"license": "ISC"
}
Third and final question, if i install them in both folders (the .node-red and the package one) when starting node red a warning is displayed about a plugin node called "sss-api", the warning is this:
[warn] [@sss/node-red-sss-dataManipulation/sss-api] TypeError: Cannot read properties of undefined (reading 'plugins')
In the code the corrispondent line is : RED.plugins.registerPlugin(PLUGIN_TYPE_ID, {
Everything seems to work fine but it just bothers me.
Bonus question :
The plugin node coudn't be installed if i put it in the package.json file under the section "plugins" so i put it in nodes and it worked, this could be relevan for the previous question.
ex:
"plugins": {
"sss-api": "sss-api.js"
}
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
Thank you for your time and have a nice day!