Custom nodes cannot be installed to Node-Red

#1

Hi,

I am creating and installing nodes programmatically. I tested this application on Ubuntu OS and it worked correctly. Then I tried this application in another Ubuntu installation and there my node is not get installed. Let me show my code briefly. I am creating a folder and required files and then install that package as npm module.

fs.mkdirSync('my_node';'0777');
//writing files into the created folder
//install node using following command
exec('npm install --prefix ~/.node-red my_node').then(.....;{

I can see the my_node folder in./node-red/node_modules folder which has lrwxrwxrwx 1 permission. (folder has shortcut mark on its icon). I opened the package.json file of node-red found in ./node-red/ folder. I can see my node has been added as a dependency. But on the machine where this node is installed fine, I cannot see that dependency.

{
    "name": "node-red-project",
    "description": "A Node-RED Project",
    "version": "0.0.1", 
   "dependencies": {
        "my_node":"file:../path/to/original/folder/which/is/created_using_mkdir"
   }
}
  1. What is the reason for getting dependency entry for my custom node? I think this is due to some problem.
  2. My code is working fine in one machine but not on others. Is this due to any version related problem of the installation?

Appreciate your insight to solve this issue.

0 Likes

#2

What versions of node.js and npm are you using on both machines?

0 Likes

#3

Hi,

Please find the versions of softwares on two machines.

Working fine -

npm version - 3.5.2
nodejs version - 8.10.0
node-red version - 0.18.7

Not Working -

npm version - 6.1.0
nodejs version - 10.6.0
node-red version - 0.18.7

Regards,
Malintha

0 Likes

#4

You are running very different versions of npm on your two machines, which explains the difference in behaviour you are seeing.

npm changed its behaviour at version 5 - it now adds anything you install to your package file by default.

1 Like

#5

Thank you for the response. I downgraded npm and nodejs to exact versions which are working fine. Now, I can see my custom node folder inside ./node-red/node_modules folder (without that shortcut mark icon) and nothing has been added to the package.json. Now, the problem not appearing the installed custom nodes on node-red UI. I am not sure about how node-red UI renders available node list. I found an entry for my custom node in .config.js file

"myNode": {
   "name": "myNode",
   "version": "1.0.0",
   "local": true,
   "nodes": {
"myNode": {
 "name": "myNode",
 "types": [
  "myNode"
 ],
 "enabled": true,
 "local": true,
 "module": "myNode",
 "file": "/home/malintha/.node-red/node_modules/myNode/myNode.js"
}
   }
  },

First I installed my custom node (with few other custom nodes) programmatically. Then I tried installing one node manually using

npm install --prefix ~/.node-red myNode

and I could see the 'successfully installed' log message along with the already installed custom nodes list.

Why can't I see my custom nodes on node-red UI?

0 Likes

#6

is there anything written to the node-red log when you restart node-red?

1 Like

#7

Have you restarted Node-RED?

0 Likes

#8

Looking at the startup log, I found and required dependency missing issue and installing it solves subsequent issues.

0 Likes