# Developing on fork of node

**URL:** <https://discourse.nodered.org/t/developing-on-fork-of-node/18927>\
**Category:** Developing Nodes\
**Created:** [8 December 2019 21:11 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927 "2019-12-08T21:11:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![bohtho](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bohtho/32/6153_2.png) [@bohtho](https://discourse.nodered.org/u/bohtho)\
**Post date:** [8 December 2019 21:11 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/1 "2019-12-08T21:11:38Z")

</div>

I plan to develop features on a contrib-node, and make a PR (my first with real code!) to the original project on GitHub.

What is the best way to do this ?

Should I change the package.json to point to my fork during development? Although it won't be published as a npm?

Should I reassign git origin of node\_module to my fork ?

Any smart ways or recipes ?

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [8 December 2019 21:26 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/2 "2019-12-08T21:26:25Z")

</div>

The easiest way I've found is to firstly stop node-RED and remove the node that you want to work on from your node-RED palette via the cli `npm remove <npm-package-name>`.

Then git clone the contrib node that you want to develop, and [follow this guide](https://nodered.org/docs/creating-nodes/first-node#testing-your-node-in-node-red) to add your local 'git' version of the node back to your palette via a symlink.

You can then start node-RED, and make whatever changes you wish to the local 'git' repo.  
When you are happy that it works as it should, you can then create a git pull request.

---

<div class="post-metadata">

**Author:** ![bohtho](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bohtho/32/6153_2.png) [@bohtho](https://discourse.nodered.org/u/bohtho)\
**Post date:** [8 December 2019 21:43 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/3 "2019-12-08T21:43:43Z")

</div>

Thanks. Hadn't thought of removing the original first. I guess I was afraid of difficulties when the flows wouldn't find the node used all over, but of course it won't get started back up before the "imposter" is linked back in the position:)

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [8 December 2019 21:46 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/4 "2019-12-08T21:46:01Z")

</div>

Yes, thats what I do anyway. I'm pretty sure someone will come along shortly and tell me I've been doing it wrong 😁 😁 😁

---

<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:** [8 December 2019 21:50 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/6 "2019-12-08T21:50:19Z")

</div>

In addition it is a good idea to do the development on a branch rather than on master. That way it is easier to identify what you have done.

---

<div class="post-metadata">

**Author:** ![bohtho](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bohtho/32/6153_2.png) [@bohtho](https://discourse.nodered.org/u/bohtho)\
**Post date:** [8 December 2019 21:53 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/8 "2019-12-08T21:53:29Z")

</div>

Yes, I believe they merge PRs to dev branch, so that is my starting point, but I then branch to "feature/[..description..]" and code there.

---

<div class="post-metadata">

**Author:** ![bohtho](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bohtho/32/6153_2.png) [@bohtho](https://discourse.nodered.org/u/bohtho)\
**Post date:** [8 December 2019 21:55 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/9 "2019-12-08T21:55:11Z")

</div>

Thanks both @Paul-Reed and @dceejay. I just think I saw a recipe some time where "npm link" was used extensively. No need then.

---

<div class="post-metadata">

**Author:** ![bohtho](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bohtho/32/6153_2.png) [@bohtho](https://discourse.nodered.org/u/bohtho)\
**Post date:** [8 December 2019 21:58 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/10 "2019-12-08T21:58:33Z")

</div>

Any thoughts on me coding this in VSCode on the mac with the Remote extension so I actually develop this on my raspberry pi ? I have to live test the node with the devices connected only to the pi. Ok ? I should just as easily be able to revert catastrophies there.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [8 December 2019 22:00 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/11 "2019-12-08T22:00:57Z")

</div>

Someone who knows more than me told me to fork and then make a new branch in your fork and make the changes in that.

Then, when making a pull-request - you do it from your new branch - it keeps things cleaner I was told

While developing, I recommend just working on the node files in an alternate install from @TotallyInformation

> [@New Utility: alternate-node-red-installer](https://discourse.nodered.org/t/new-utility-alternate-node-red-installer/13490):
>
> Hi all, as I'm needing to install some clean installations of Node-RED for testing, I thought that I would finally get round to writing a proper tool for installing multiple independent instances of Node-RED. I've just finished that off and published to GitHub and npm so you should be able to use it straight away if you have a need for such a thing. It gives you a command-line installer that takes a single parameter controlling the root folder for installation. It should work on all platforms. …

Once I'm happy with changes - I then just copy/paste from local files into the github branch created earlier

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [8 December 2019 22:02 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/12 "2019-12-08T22:02:38Z")

</div>

> [@bohtho](#):
>
> Any thoughts on me coding this in VSCode on the mac with the Remote extension so I actually develop this on my raspberry pi ?

I don't use VSCode but I use Notepad++ in this manner to do the editing so it should work

---

<div class="post-metadata">

**Author:** ![bohtho](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bohtho/32/6153_2.png) [@bohtho](https://discourse.nodered.org/u/bohtho)\
**Post date:** [8 December 2019 22:05 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/13 "2019-12-08T22:05:36Z")

</div>

Thanks for the input from experience!

I would like to try to get more familiar with git in the process and be as "pro" as is possible, so I would have thought I could "checkout" the master branch again when pausing development (instead of switching between node-red installations) ? Even from the node-red GUI I believe ?

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [8 December 2019 22:07 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/14 "2019-12-08T22:07:57Z")

</div>

Well there's your suggested method and my KISS one 🙂

Choose wisely Padawan 🙂

In seriousness - mine works well if its just changing the .js file and can cope if its the .html file as well - once the changes get more complex than that - then prob full on git starts to be worth it

---

<div class="post-metadata">

**Author:** ![bohtho](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bohtho/32/6153_2.png) [@bohtho](https://discourse.nodered.org/u/bohtho)\
**Post date:** [8 December 2019 22:11 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/15 "2019-12-08T22:11:37Z")

</div>

I'm practically sure I will accidentally kill an Ewok or two here, but until then I have my mind set on the learning part of all this 🙂 I did take note of your way though.

---

<div class="post-metadata">

**Author:** ![bohtho](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bohtho/32/6153_2.png) [@bohtho](https://discourse.nodered.org/u/bohtho)\
**Post date:** [8 December 2019 22:18 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/16 "2019-12-08T22:18:50Z")

</div>

> [@bohtho](#):
>
> Even from the node-red GUI I believe ?

Actually, the branch switching inside the node-RED GUI is related to my flows/project of course, and to make that switching work in this case I would have to have two different package.json files, keep the original node in place on my project's master branch, and also restart all of node-red when switching.... ? Maybe that's a step too far for me, or did I just confuse myself again ?

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [8 December 2019 22:22 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/17 "2019-12-08T22:22:58Z")

</div>

all I heard was something about kilts ......... 🙂

---

<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:** [10 December 2019 09:16 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/18 "2019-12-10T09:16:58Z")

</div>

> [@Paul-Reed](#):
>
> I'm pretty sure someone will come along shortly and tell me I've been doing it wrong

Well ... 🤣

> [@bohtho](#):
>
> "npm link"

You don't need to do that any more. You can simply do an npm install against a folder name and npm will work it all out for you. In your package.json it will use a `file:` reference.

> [@cymplecy](#):
>
> I recommend just working on the node files in an alternate install from @TotallyInformation

Me too 😀

Especially if you need different configurations to test. For example, using `httpRoot`, projects, etc.

---

<div class="post-metadata">

**Author:** ![bohtho](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bohtho/32/6153_2.png) [@bohtho](https://discourse.nodered.org/u/bohtho)\
**Post date:** [10 December 2019 11:27 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/19 "2019-12-10T11:27:54Z")

</div>

I’m only experimenting with code in this particular node for now.

And when finished (accepted PR, etc) I just npm install the original node from npm over it again?

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [10 December 2019 13:20 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/20 "2019-12-10T13:20:38Z")

</div>

> [@bohtho](#):
>
> I just npm install the original node from npm over it again?

Maybe it's not necessary, but I usually remove the 'git' version before installing the original node.

Stop node-RED  
`npm uninstall ~/dev/node-red-contrib-example-node` - (path to your project)  
`npm install <npm-package-name>` - install original  
Start node-RED

---

<div class="post-metadata">

**Author:** ![bohtho](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bohtho/32/6153_2.png) [@bohtho](https://discourse.nodered.org/u/bohtho)\
**Post date:** [10 December 2019 22:37 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/21 "2019-12-10T22:37:32Z")

</div>

I really appreciate it getting all new necessary knowledge (To contribute!) from this helpful community!

I’m too wary, or just too ahead of myself here, but if you would still indulge on my first mini-coding-project:

“Npm install ” links “node\_modules” to my node code, so I will only have to restart node-red to test a new iteration? Or will I have to increase a fictive version number too and reinstall it every time?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [10 December 2019 23:50 UTC](https://discourse.nodered.org/t/developing-on-fork-of-node/18927/22 "2019-12-10T23:50:27Z")

</div>

If it is local just stop and restart. No re-install or version number change necessary.

[Next page](https://discourse.nodered.org/t/developing-on-fork-of-node/18927.md?page=2)
