How to install node types?

Hello,

I'm new to node-red, and I need help with installing node types.
When I run the project it says:

Flows stopped due to missing node types.
sf:3f24e8e108a6d3cc
sf:827ff8967a4e86f6

And I have them in separate folder, in main project folder (.node-red), in package.json I have included them(setworkmode and uimonad).

{
    "name": "node-red-project",
    "description": "A Node-RED Project",
    "version": "0.0.1",
    "private": true,
    "dependencies": {
        "node-red-contrib-bigexec": "~1.3.3",
        "node-red-contrib-modbus": "~5.23.1",
        "node-red-contrib-ui-contextmenu": "~2.0.1",
        "node-red-contrib-ui-led": "~0.4.11",
        "node-red-contrib-ui-multistate-switch": "~1.2.3",
        "node-red-dashboard": "~3.1.7",
        "setworkmode": "file:../subflowModules/setworkmode",
        "uimonad": "file:../subflowModules/uimonad"
    }
}

Inside those 2 folders(setworkmode and uimonad) are index.js, package.json and subflow.json that former colleague has created.

And in CMD it says:

13 Apr 12:16:20 - [info] Waiting for missing types to be registered:
13 Apr 12:16:20 - [info]  - sf:3f24e8e108a6d3cc
13 Apr 12:16:20 - [info]  - sf:827ff8967a4e86f6```

Have you run npm install since adding them to package.json? You need to do that to get npm to create the necessary symlnks from /.node-red/node_modules to where the nodes are.

I have, but i get this:

C:\Users\Marko>npm install
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\Marko/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Marko\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Marko\AppData\Local\npm-cache\_logs\2023-04-13T10_18_48_898Z-debug-0.log

I'm not 100% sure where files need to be located.

You need to run npm install in the same directory as your package.json file - .node-red

I did it like this:

C:\Users\Marko>npm install C:\Users\Marko\.node-red

removed 151 packages, changed 2 packages, and audited 164 packages in 4s

20 packages are looking for funding
  run `npm fund` for details

7 vulnerabilities (4 moderate, 3 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.

But now I don't have any other nodes in palette except node-red and setworkmode, and more of the nodes in the project are red line dashed

That is not what I said to do.

You should run npm install from in the directory C:\Users\Marko\.node-red

cd C:\Users\Marko\.node-red
npm install

I did it like that now, but I'm still missing uimonad node in palette

What is in package.json?

In uimonad package.jason is:

{
  "name": "uimonad",
  "version": "1.0.0",
  "description": "Ensure UI text reacts to errors and fetch prompts.",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "monad",
    "error",
    "init",
    "ui"
  ],
  "author": "Toni Opuhač",
  "license": "ISC",
  "node-red": {
    "nodes": {
      "uimonad": "index.js"
    },
    "dependencies": [
      "node-red-contrib-bigexec",
      "node-red-contrib-modbus",
      "node-red-contrib-ui-contextmenu",
      "node-red-contrib-ui-led",
      "node-red-contrib-ui-multistate-switch",
      "node-red-dashboard"
    ]
  },
  "dependencies": {
    "node-red-contrib-bigexec": "~1.3.3",
    "node-red-contrib-modbus": "~5.23.1",
    "node-red-contrib-ui-contextmenu": "~2.0.1",
    "node-red-contrib-ui-led": "~0.4.11",
    "node-red-contrib-ui-multistate-switch": "~1.2.3",
    "node-red-dashboard": "^3.4.0"
  }
}

As you can see, that is messed up. It may have been the incorrect npm install that you did earlier that caused that. Fix that, then I may be wrong, but I don't think it is a good idea to put the linked nodes under the .node-red folder, I think I had problems doing that at some point. Move them out to separate folders and remove those entries from package.json. Then to get the subflowmodules installed, go into the .node-red folder and run
npm install /path/to/subflowModules/setworkmode
and the same for the other one. Then restart node red.

If you are not sure how to fix package.json then delete it and the node_modules folder. Then restart node-red. It will complain that there are missing nodes. Install those again, which you can do from inside node-red, then manually install your nodes as described above and restart node-red.

Category changed to general as the post is not about "developing nodes" :grinning:

Could you explain to me from start, so 0, I just opened new project and I only want to install for example setworkmode node type, how do you do that? Things that I have are only folder setworkmode and inside are files:
index.js

 const fs = require("fs");
 const path = require("path");

 module.exports = function(RED) {
     const subflowFile = path.join(__dirname,"subflow.json");
     const subflowContents = fs.readFileSync(subflowFile);
     const subflowJSON = JSON.parse(subflowContents);
     RED.nodes.registerSubflow(subflowJSON);
 }

package.json

{
  "name": "setworkmode",
  "version": "1.0.0",
  "description": "Set work mode of leCPS.",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "leCPS",
    "work",
    "mode",
    "set"
  ],
  "author": "Toni Opuhač",
  "license": "ISC",
  "node-red": {
    "nodes": {
      "Set work mode state": "index.js"
    },
    "dependencies": [
        "node-red-contrib-bigexec",
        "node-red-contrib-modbus",
        "node-red-contrib-ui-contextmenu",
        "node-red-contrib-ui-led",
        "node-red-contrib-ui-multistate-switch",
        "node-red-dashboard",
        "uimonad"
    ]
  },
  "dependencies": {
        "node-red-contrib-bigexec": "~1.3.3",
        "node-red-contrib-modbus": "~5.23.1",
        "node-red-contrib-ui-contextmenu": "~2.0.1",
        "node-red-contrib-ui-led": "~0.4.11",
        "node-red-contrib-ui-multistate-switch": "~1.2.3",
        "node-red-dashboard": "~3.1.7",
        "uimonad": "file:../subflowModules/uimonad"
  }
}

subflow.json

{
"id": "827ff8967a4e86f6",
"type": "subflow",
"name": "Set work mode state",
"info": "",
"category": "function",
"in": [
    {
	"x": 40,
	"y": 140,
	"wires": [
	    {
		"id": "7056865d556523f1"
	    }
	]
    }
],
"out": [
    {
	"x": 750,
	"y": 140,
	"wires": [
	    {
		"id": "352ddb6a0cdcfbab",
		"port": 0
	    },
	    {
		"id": "c348f6c2462bd906",
		"port": 0
	    },
	    {
		"id": "ca9ca3c8f60b1653",
		"port": 0
	    },
	    {
		"id": "8e980d04beae8cd6",
		"port": 0
	    }
	]
    }
],
"env": [],
"meta": {},
"color": "#FFAAAA",
"inputLabels": [
    "CPS modbus payload"
],
"outputLabels": [
    "Colored text representing state"
],
"icon": "node-red/swap.svg",
"flow": [
    {
        "id": "352ddb6a0cdcfbab",
        "type": "template",
        "z": "827ff8967a4e86f6",
        "name": "Set state local-automatic",
        "field": "payload",
        "fieldType": "msg",
        "format": "json",
        "syntax": "mustache",
        "template": "{\n    \"color\": \"brown\",\n    \"valueText\": \"Trenutno stanje lokalnog-automatskog upravljanja\"\n}",
        "output": "json",
        "x": 470,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "c348f6c2462bd906",
        "type": "template",
        "z": "827ff8967a4e86f6",
        "name": "Set state remote",
        "field": "payload",
        "fieldType": "msg",
        "format": "json",
        "syntax": "mustache",
        "template": "{\n    \"color\": \"blue\",\n    \"valueText\": \"Trenutno stanje daljinskog načina upravljanja\"\n} ",
        "output": "json",
        "x": 440,
        "y": 120,
        "wires": [
            []
        ]
    },
    {
        "id": "ca9ca3c8f60b1653",
        "type": "template",
        "z": "827ff8967a4e86f6",
        "name": "Set state local",
        "field": "payload",
        "fieldType": "msg",
        "format": "json",
        "syntax": "mustache",
        "template": "{\n    \"color\": \"green\",\n    \"valueText\": \"Trenutno stanje lokalnog načina upravljanja\"\n}",
        "output": "json",
        "x": 440,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "8e980d04beae8cd6",
        "type": "template",
        "z": "827ff8967a4e86f6",
        "name": "Set state undefined",
        "field": "payload",
        "fieldType": "msg",
        "format": "json",
        "syntax": "mustache",
        "template": "{\n    \"color\": \"purple\",\n    \"valueText\": \"Trenutno stanje nije ispravno definirano\"\n}",
        "output": "json",
        "x": 450,
        "y": 200,
        "wires": [
            []
        ]
    },
    {
        "id": "7056865d556523f1",
        "type": "switch",
        "z": "827ff8967a4e86f6",
        "name": "Check work mode state",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "1",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "2",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "3",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 4,
        "x": 210,
        "y": 140,
        "wires": [
            [
                "352ddb6a0cdcfbab"
            ],
            [
                "c348f6c2462bd906"
            ],
            [
                "ca9ca3c8f60b1653"
            ],
            [
                "8e980d04beae8cd6"
            ]
        ]
    }
]
}

Where do I need to put that folder and what do I need to type and where? Step-by-step please, I'm just starting so I don't know much.

Firstly, do not manually edit package.json. If you have already done that then start again.

To install your node, in a command window, cd to your .node-red folder and, as I said above, run
npm install /path/to/your/node
then restart node-red.
I also said that I think I have had problems if the node is under the .node-red folder so it may be best to move it out of there.

Thank you soo much, it worked

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