# Node-RED projects vs. "normal committing + pushing with git"

**URL:** <https://discourse.nodered.org/t/node-red-projects-vs-normal-committing-pushing-with-git/67374>\
**Category:** General\
**Tags:** docker\
**Created:** [6 September 2022 06:49 UTC](https://discourse.nodered.org/t/node-red-projects-vs-normal-committing-pushing-with-git/67374 "2022-09-06T06:49:59Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kitkat159](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kitkat159/32/66066_2.png) [@kitkat159](https://discourse.nodered.org/u/kitkat159)\
**Post date:** [6 September 2022 06:49 UTC](https://discourse.nodered.org/t/node-red-projects-vs-normal-committing-pushing-with-git/67374/1 "2022-09-06T06:49:59Z")

</div>

I run NR under Docker and use a bind mount to map a local folder.  
I use an NR project with a remote repository and since I also wanted to have a NR runtime defined, I have another repository to store the "settings.js", Dockerfile, Readme etc.

As far as I understand, the main advantage of using NR projects is that you can switch between projects. This is also good, as I want to switch between projects in development.

But my main goal is to create containers from the projects, but with the runtime defined in the other repository. This is where it gets tricky: I don't want to have projects enabled in the final container.

I don't know... there's something I can't wrap my head around. How would you do this?

Maybe I should forget NR projects at all then and store every project with a separate settings.js? But what if I make changes?

Maybe I am overthinking this and there is an easy solution...  
I'm interested in your ideas!

---

<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:** [6 September 2022 08:26 UTC](https://discourse.nodered.org/t/node-red-projects-vs-normal-committing-pushing-with-git/67374/2 "2022-09-06T08:26:42Z")

</div>

I use git for source control of my node-red systems, but not using projects. I simple commit the .node-red folder in each case, using this .gitignore file to leave out unnecessary files

```auto
*.backup*
node_modules
nodes
dist
context
.config.users.json

```

When deploying to a new system it is just necessary (after installing node-red) to clone that and run, from that directory  
`npm install`  
to install all necessary nodes.

To make git diffs more useful when looking at the flows file, I set flowFilePretty in settings.js (and deploy after making that change) and run this script before committing. That generates a more human readable version of the flows file with function nodes expanded so that diffs can be seen within functions.

```auto
#!/usr/bin/env sh

# generates formatted versions of node red flow files matching flow*.json
# in files flow*.json.formatted

# NOTE must have flowFilePretty: true in settings.js

for f in flow*.json; do
  echo $f
  sed -r 's/\\n/\n/g' "$f" > "$f.formatted"
done
# remove any cred files converted
rm *_cred.json.formatted

```

---

<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:** [6 September 2022 08:36 UTC](https://discourse.nodered.org/t/node-red-projects-vs-normal-committing-pushing-with-git/67374/3 "2022-09-06T08:36:16Z")

</div>

> [@Colin](#):
>
> When deploying to a new system it is just necessary (after installing node-red) to clone that and run, from that directory  
> `npm install`  
> to install all necessary nodes.

Of course, if you adjust your package.json file, you can use npm to install a clone direct from GitHub and get it to do the install automatically using the `postinstall` script feature. 🙂

---

<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:** [6 September 2022 08:49 UTC](https://discourse.nodered.org/t/node-red-projects-vs-normal-committing-pushing-with-git/67374/4 "2022-09-06T08:49:31Z")

</div>

I will have to look into that. Thanks.

---

<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:** [6 September 2022 08:51 UTC](https://discourse.nodered.org/t/node-red-projects-vs-normal-committing-pushing-with-git/67374/5 "2022-09-06T08:51:16Z")

</div>

No problem, give me a shout if you need any help.

---

<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:** [6 September 2022 13:04 UTC](https://discourse.nodered.org/t/node-red-projects-vs-normal-committing-pushing-with-git/67374/6 "2022-09-06T13:04:18Z")

</div>

> [@TotallyInformation](#):
>
> use npm to install a clone direct from GitHub

I can't immediately see how to use npm to clone the complete .node-red directory. Can you point me in the right direction?

---

<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:** [6 September 2022 14:14 UTC](https://discourse.nodered.org/t/node-red-projects-vs-normal-committing-pushing-with-git/67374/7 "2022-09-06T14:14:02Z")

</div>

Assuming your github repository contains everything including the package.json file that lives in your userDir, you should simply be able to:

```auto
mkdir new_nr
npm install --prefix ./new_nr mygithubid/mygithubreponame

```

That should clone everything in the repo to `new_nr`.

What it doesn't do is leave you with a new git in the new folder, you would need to do that separately if you wanted to.

The nice thing is though that you could update this instance from github just with `npm update --prefix ./new_nr mygithubid/mygithubreponame` or, add a script to the package.json:

```auto
  "update": "npm install --prefix ./ mygithubid/mygithubreponame",

```

If you were using my alternate installer, you could remove my template `./data` folder from the parent folder, then do the install as `npm install --prefix ./data mygithubid/mygithubreponame` which would add your repo to the parent package.json and you could then update it simply with an `npm update` I think.

npm is fun when you start exploring its capabilities.

* * *

PS: Should have warned you that I didn't actually TRY these commands! Sorry. But I think it should work.

---

<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:** [6 September 2022 14:31 UTC](https://discourse.nodered.org/t/node-red-projects-vs-normal-committing-pushing-with-git/67374/8 "2022-09-06T14:31:07Z")

</div>

> [@TotallyInformation](#):
>
> ```auto
> mkdir new_nr
> npm install --prefix ./new_nr mygithubid/mygithubreponame
> 
> ```
> 
> That should clone everything in the repo to `new_nr`.

My repo contains the .node-red folder contents, so the flows file, settings.js etc. After running that command all I have in new\_nr is package.json (containing just a dependency of the github repo), package-lock.json and node\_modules. The files that should be in the top level are buried away in node\_modules.

---

<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:** [6 September 2022 20:10 UTC](https://discourse.nodered.org/t/node-red-projects-vs-normal-committing-pushing-with-git/67374/9 "2022-09-06T20:10:25Z")

</div>

Ah, I did wonder about that. I think there may be a way to overcome that but not sure. Sorry, going to be mostly offline for a week or two. Some googling may turn up more.

---

<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:** [6 September 2022 20:23 UTC](https://discourse.nodered.org/t/node-red-projects-vs-normal-committing-pushing-with-git/67374/10 "2022-09-06T20:23:33Z")

</div>

For me it isn't an issue anyway, as I use Ansible scripts for deploying and the script includes the `npm install` after the clone. So the whole thing is automatic anyway.

---

<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:** [5 November 2022 20:24 UTC](https://discourse.nodered.org/t/node-red-projects-vs-normal-committing-pushing-with-git/67374/11 "2022-11-05T20:24:06Z")

</div>

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