# Where to start to import your npm package

**URL:** <https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799>\
**Category:** General\
**Created:** [3 June 2019 15:39 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799 "2019-06-03T15:39:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pviljoen](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@pviljoen](https://discourse.nodered.org/u/pviljoen)\
**Post date:** [3 June 2019 15:39 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/1 "2019-06-03T15:39:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [3 June 2019 15:47 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/2 "2019-06-03T15:47:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pviljoen](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@pviljoen](https://discourse.nodered.org/u/pviljoen)\
**Post date:** [3 June 2019 15:49 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/3 "2019-06-03T15:49:29Z")

</div>

It is published into NPM already.

---

<div class="post-metadata">

**Author:** ![pviljoen](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@pviljoen](https://discourse.nodered.org/u/pviljoen)\
**Post date:** [3 June 2019 15:50 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/4 "2019-06-03T15:50:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [3 June 2019 15:56 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/5 "2019-06-03T15:56:17Z")

</div>

EH?

> [@pviljoen](#):
>
> published into NPM already

> [@pviljoen](#):
>
> and Yes . I want to use a published npm package

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](https://nodered.org/docs/creating-nodes/packaging) you will see it tells you to add `node-red` in the `package.json` keywords. That key-word is necessary for [nodered.org](http://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.

---

<div class="post-metadata">

**Author:** ![pviljoen](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@pviljoen](https://discourse.nodered.org/u/pviljoen)\
**Post date:** [3 June 2019 16:02 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/6 "2019-06-03T16:02:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pviljoen](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@pviljoen](https://discourse.nodered.org/u/pviljoen)\
**Post date:** [3 June 2019 16:08 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/7 "2019-06-03T16:08:03Z")

</div>

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 ?)

---

<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:** [3 June 2019 16:11 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/8 "2019-06-03T16:11:43Z")

</div>

Hi @pviljoen

> [@pviljoen](#):
>
> Yes it is published in npm. Now I want to use that package inside node-red (import) through palette.

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.

> [@pviljoen](#):
>
> after running the NPM command line process from within . node red, I can see the directory structure created under the modules subdir.

What command did you run?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [3 June 2019 16:18 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/9 "2019-06-03T16:18:18Z")

</div>

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](https://www.npmjs.com/package/node-red-contrib-got)

---

<div class="post-metadata">

**Author:** ![pviljoen](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@pviljoen](https://discourse.nodered.org/u/pviljoen)\
**Post date:** [3 June 2019 16:26 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/10 "2019-06-03T16:26:30Z")

</div>

it is woocommerce. [https://www.npmjs.com/package/woocommerce](https://www.npmjs.com/package/woocommerce)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [3 June 2019 16:34 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/11 "2019-06-03T16:34:17Z")

</div>

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

node-red nodes are here [https://flows.nodered.org/](https://flows.nodered.org/)

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

---

<div class="post-metadata">

**Author:** ![pviljoen](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@pviljoen](https://discourse.nodered.org/u/pviljoen)\
**Post date:** [3 June 2019 16:36 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/12 "2019-06-03T16:36:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [3 June 2019 16:38 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/13 "2019-06-03T16:38:08Z")

</div>

> [@pviljoen](#):
>
> so what are the perquisite and changes that needed

Its all here...  
[https://nodered.org/docs/creating-nodes/](https://nodered.org/docs/creating-nodes/)

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.

---

<div class="post-metadata">

**Author:** ![pviljoen](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@pviljoen](https://discourse.nodered.org/u/pviljoen)\
**Post date:** [3 June 2019 16:41 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/14 "2019-06-03T16:41:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pviljoen](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@pviljoen](https://discourse.nodered.org/u/pviljoen)\
**Post date:** [3 June 2019 17:03 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/15 "2019-06-03T17:03:00Z")

</div>

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",  
and  
"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?

---

<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:** [3 June 2019 17:22 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/16 "2019-06-03T17:22:19Z")

</div>

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.

---

<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:** [3 June 2019 17:33 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/17 "2019-06-03T17:33:33Z")

</div>

`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.

---

<div class="post-metadata">

**Author:** ![pviljoen](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@pviljoen](https://discourse.nodered.org/u/pviljoen)\
**Post date:** [3 June 2019 17:40 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/18 "2019-06-03T17:40:12Z")

</div>

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.  
[https://nodered.org/docs/creating-nodes/first-node](https://nodered.org/docs/creating-nodes/first-node)

---

<div class="post-metadata">

**Author:** ![pviljoen](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@pviljoen](https://discourse.nodered.org/u/pviljoen)\
**Post date:** [3 June 2019 17:51 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/19 "2019-06-03T17:51:55Z")

</div>

So continuing from the [https://nodered.org/docs/creating-nodes/first-node](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)  
|-sample.js(lowercase.js)  
-icons  
-sample.png
- README.md
- LICENSE

```auto

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.
```

---

<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:** [3 June 2019 18:03 UTC](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799/20 "2019-06-03T18:03:23Z")

</div>

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.

[Next page](https://discourse.nodered.org/t/where-to-start-to-import-your-npm-package/11799.md?page=2)
