Where to start to import your npm package

I am a beginner at this so please be patient. I want to import an existing NPM package into node red. I followed the documents in node-red how to publish your package but I am experiencing weird things like my whole module sub-dir disappearing when I do the link command.
Is their some documentation I can read to understand the process?
Where do I start?
what is the procedure to do this?

Have you developed a node-red node and published it to npm? (That's the name of it or provide a link)

Or are you trying to use a normal npm package in node-red?

It is published into NPM already.

and Yes . I want to use a published npm package in node-red.


Its either published or its not????

So let me guess. You have published a new type of node-red node to NPM but its not appearing in node-red pallete? If so, then did you read this you will see it tells you to add node-red in the package.json keywords. That key-word is necessary for nodered.org to pick it up and create an entry in the pallete

What is the name of your package?
And what do you mean by sub directories missing?

Your information is very unclear.

Ok, do you import or publish to node-red?
Yes it is published in npm. Now I want to use that package inside node-red (import) through palette.

Tried via the node-red documented process. I guess I have not seen clear steps?
I have added the node-red (script) to the parent directory package file. (Top level)
Do I have to include that in all the sub-dir package files?
How important is the package .html file?

after running the NPM command line process from within . node red, I can see the directory structure created under the modules subdir.
I then update the package file according to the notes\documentation. I then run link cmd first in the subdir for the main package folder and then from withing the .node-red folder.
If I do a refresh on my node-modules folder, the new package folder and directory structure is gone.(Deleted ?)

Hi @pviljoen

It would help a lot if you told us the name of the module. If you have already published it to npm, then we can take a look at it directly.

What command did you run?

it sounds like you are mixing up methods of installation & confusing npm installation method with local linking and pallete installation.

If you give us the name of the npm package we can check it is correctly published.

it is my guess you havent published all the necessary parts in your npm package.

Please add a link to the NPM package e.g. https://www.npmjs.com/package/node-red-contrib-got

it is woocommerce. https://www.npmjs.com/package/woocommerce

This is not a node-red node & cannot (easily) be used.

node-red nodes are here https://flows.nodered.org/

you could try this https://flows.nodered.org/node/node-red-contrib-npm - it permits use of NON "node-red" nodes (though I've never used it)

so what are the perquisite and changes that needed to be added to be able to do this?

Its all here...

and there are thousands of finished working node-red nodes in github that you can draw experience and examples from of turning a NON node-red "nodejs" module into a "proper" node-red node.

Understood. My goal is to do setup procedure to get it in the node-red library. Currently there are very little commerce nodes in the library.

Is it Ok to ask questions here Or is there a specific place for it
for example.
The sample talks about the package.js file but the code sample refers to it as
"name" : "node-red-contrib-example-lower-case",
"name": "package",
which one is correct?
The documents start out as creating a folder "lower-case", but the install refers to a subdir of "node-red-contrib-example-lower-case". At what stage do you change this?

You don't rename the folder.

It would really help if you linked to the section/page in the docs you refer to each time. Otherwise we have to guess what you are reading and misunderstanding.

node-red-contrib-example-lower-case is the name of the top level directory under which all of your modules files will exist. The package.json file, the readme.md file etc.

lower-case is a directory inside that top level directory where the node's .js and .html files are placed. You don't need to do that, but it can help to organise things if a module contains multiple nodes.

Thank you I appreciate your Guidance. I just need to make sure how to move from a simple example to a more complicated node and directory structure.

So continuing from the https://nodered.org/docs/creating-nodes/first-node page and going to the packing page.
The file structure should read
/node-red-contrib-example-lower-case - directory under node-modules`

  • package.json
  • sample (lowercase >subdir)
    |-sample.html (lowercase.html)
  • README.md

Is this correct?
My apologies if I am over simplifying, but I have to create a step by step task procedure for my o-team.

I don't know what an o-team is, but I would hope the docs are reasonably clear.

How much JavaScript and/or node.js experience do you or your team have? Creating a node for node-red does require a basic grasp of these things; the docs have to assume a certain baseline of experience.

You can put the node's js and html files wherever you want in the structure. The main thing is their entry in the package.json file points at them.