# How create new nodes?

**URL:** <https://discourse.nodered.org/t/how-create-new-nodes/77746>\
**Category:** Developing Nodes\
**Created:** [20 April 2023 16:19 UTC](https://discourse.nodered.org/t/how-create-new-nodes/77746 "2023-04-20T16:19:11Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![namexx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/namexx/32/72976_2.png) [@namexx](https://discourse.nodered.org/u/namexx)\
**Post date:** [20 April 2023 16:19 UTC](https://discourse.nodered.org/t/how-create-new-nodes/77746/1 "2023-04-20T16:19:11Z")

</div>

Hello guys, I'm trying to create my first node in Node-RED, but I haven't been successful so far.  
I'm using the lower-case example from Node-RED.

The steps I'm following are the following:  
1.-create folder in directory .node-red/node-modules/  
2.-I'm creating the files package.json, lowercase.json, and lowercase.html.(In the package.json file, I'm defining the location of lowercase.json)  
3.- Restart node-red

These steps haven't worked for me, what can I do? Could you help me with an example or point out where I'm going wrong or skipping?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 April 2023 16:26 UTC](https://discourse.nodered.org/t/how-create-new-nodes/77746/2 "2023-04-20T16:26:19Z")

</div>

> [@namexx](#):
>
> create folder in directory .node-red/node-modules/

No, you can't do it there.

Node-RED is a node.js app. So you should generally follow the development process for a node.js module, that is then packaged via [npmjs.org](http://npmjs.org) and so available to Node-RED.

To develop, the best workflow is to create a new GitHub repository. Clone it to your local development machine. Go into the folder you cloned to and do `npm init -y` to give yourself a package.json file.

Then you should be able to install the module into node-red simply by switching to your userDir folder (e.g. `~/.node-red/`) and doing `npm install /path/to/my/clone/folder`.

Finally restart node-red.

* * *

To make changes to the code, all you then have to do is save the file and restart node-red. For changes to the html file, you will also have to reload the Editor page.

You can use something like PM2 to run node red on your dev device and configure it with a watch config so that node-red restarts when an appropriate file changes. That saves some effort.

* * *

To use the lowercase node as an example, do the same but copy in the 3 files before restarting Node-RED. Or copy them into your original GitHub repo before cloning.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [20 April 2023 16:28 UTC](https://discourse.nodered.org/t/how-create-new-nodes/77746/4 "2023-04-20T16:28:55Z")

</div>

And to keep things organised: I have moved this to the **Developing Nodes** category

---

<div class="post-metadata">

**Author:** ![namexx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/namexx/32/72976_2.png) [@namexx](https://discourse.nodered.org/u/namexx)\
**Post date:** [20 April 2023 16:42 UTC](https://discourse.nodered.org/t/how-create-new-nodes/77746/5 "2023-04-20T16:42:11Z")

</div>

I think I understood something. But could you explain it a little more detailed.

I create my directory in the path /root/myexample. Then in this directory, I initialize a git and use npm init to create the package.json file.

And Then I create my lower-case.html and js files (/root/myexample).

But then how do I install it in Node-Red?

I understand that you tell me that I should use "npm install /root/myexample" inside folder .node-red/node\_module ?

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [20 April 2023 16:48 UTC](https://discourse.nodered.org/t/how-create-new-nodes/77746/6 "2023-04-20T16:48:33Z")

</div>

> [@namexx](#):
>
> I understand that you tell me that I should use "npm install /root/myexample" inside folder .node-red/node\_module ?

Hi @namexx

Do it within your `.node-red` dir

Im going to assume you work in `root`

```auto
cd /root/.node-red
npm install <root DIR of your poject> <- the Dir that your package.json is in

```

Example

```auto
cd /root/.node-red
npm install /root/development-projects/kick-ass-node

```

This wil install into `/root/.node-red/node_modules` \<- no need (In fact, Dont) be in the **node\_modules** dir when running install

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 April 2023 16:50 UTC](https://discourse.nodered.org/t/how-create-new-nodes/77746/7 "2023-04-20T16:50:22Z")

</div>

> [@namexx](#):
>
> I create my directory in the path /root/myexample. Then in this directory, I initialize a git and use npm init to create the package.json file.

Yes.

> [@namexx](#):
>
> And Then I create my lower-case.html and js files (/root/myexample).

Yes, but copy over the package.json as well since you need the node-red entries from it.

> [@namexx](#):
>
> But then how do I install it in Node-Red?
> 
> I understand that you tell me that I should use "npm install /root/myexample" inside folder .node-red/node\_module ?

```auto
cd ~/.node-red
npm install /root/myexample

```

---

<div class="post-metadata">

**Author:** ![k5map](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/k5map/32/47681_2.png) [@k5map](https://discourse.nodered.org/u/k5map)\
**Post date:** [20 April 2023 21:17 UTC](https://discourse.nodered.org/t/how-create-new-nodes/77746/8 "2023-04-20T21:17:37Z")

</div>

@TotallyInformation ... I also am in the process of writing my own node and have one question on the setup. I read on one of the NR doc pages that we should exclude the "node-red" section on the package.json file until we are ready to release it to the public. Could you provide some clarity on if that is true or not?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 April 2023 00:16 UTC](https://discourse.nodered.org/t/how-create-new-nodes/77746/9 "2023-04-21T00:16:59Z")

</div>

Not the node-red section, don't add a "node-red" keyword. That means that if you publish it, it won't appear in the node-red palette manager or the flows site until you are ready for it to be publicly usable. You can still get people to test it by installing from the command line.

---

<div class="post-metadata">

**Author:** ![k5map](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/k5map/32/47681_2.png) [@k5map](https://discourse.nodered.org/u/k5map)\
**Post date:** [21 April 2023 01:40 UTC](https://discourse.nodered.org/t/how-create-new-nodes/77746/10 "2023-04-21T01:40:58Z")

</div>

@TotallyInformation ... ah ok, much thanks for that clarification

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 April 2023 08:40 UTC](https://discourse.nodered.org/t/how-create-new-nodes/77746/11 "2023-04-21T08:40:13Z")

</div>

Also note that there is no need to publish it on npm before it is ready for general use. If you are not publishing it on npm then you can include the keyword immediately.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 June 2023 08:40 UTC](https://discourse.nodered.org/t/how-create-new-nodes/77746/12 "2023-06-20T08:40:40Z")

</div>

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