# Shared system folders in multi user instances?

**URL:** <https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882>\
**Category:** General\
**Created:** [6 February 2022 18:03 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882 "2022-02-06T18:03:01Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![corso66](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/corso66/32/41143_2.png) [@corso66](https://discourse.nodered.org/u/corso66)\
**Post date:** [6 February 2022 18:03 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/1 "2022-02-06T18:03:01Z")

</div>

Hello,

I tested multi users by running more than one nodered instances in the same machine, same flow for each.

I want to know if it is possible to share from the main nodered admin folder, for exemple "node-modules" and ".npm" folder witch take both a lot of disk space ?

I have read the settings.js, and i can't see any option for 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 February 2022 20:02 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/2 "2022-02-06T20:02:21Z")

</div>

Lots of ways you could approach this. You should do some background reading on how node.js and npm works.

Obviously all instances of node-red can use the same master package. And you will find that, if you do manual installs rather using the "Manage palette" menu, you can install nodes at the same level as node-red itself. Personally, I find this easier when doing local installs rather than global. If you install node-red into a folder (as is common for many node.js applications), you can install nodes into the same folder. Then run multiple instances from that install. Of course, users would not be able to uninstall those nodes.

You could also share the node\_modules folder from a userDir folder as well. However, everyone who had access to the folder could install/uninstall to/from it which wouldn't be very safe. In addition, the instances that hadn't done the install would need some separate process to update their package.json files. That is avoided if you install to the parent node-red level, all that is needed is to restart each instance.

---

<div class="post-metadata">

**Author:** ![corso66](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/corso66/32/41143_2.png) [@corso66](https://discourse.nodered.org/u/corso66)\
**Post date:** [7 February 2022 11:03 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/3 "2022-02-07T11:03:27Z")

</div>

Ok.

As you say, global install or local install... Everytime i create a new user, i need to install nodered for this user, locally ?  
Do you think i can make a symbolic link from a home user that point to node\_modules ? That all ?

Here is how i see that, globaly i would want to build a linux script to create a user :

Consider i have a `shared_user_folder`:

- Create a new user
- install node-red
- copy the application flow (and eventualy settings.js) in the .nodered folder
- Create a link that point to the main user folder `/shared_user_folder/node_module`

That a good way ?

---

<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:** [7 February 2022 11:20 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/4 "2022-02-07T11:20:46Z")

</div>

> [@corso66](#):
>
> Everytime i create a new user, i need to install nodered for this user, locally ?

Not if you use a global install. Then they will all use the same node-red and global node\_modules. Of course then you cannot have different versions of node red for different users.

---

<div class="post-metadata">

**Author:** ![corso66](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/corso66/32/41143_2.png) [@corso66](https://discourse.nodered.org/u/corso66)\
**Post date:** [7 February 2022 13:01 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/5 "2022-02-07T13:01:55Z")

</div>

Sorry, i'm confused.

I must to do global install of nodered to use linked `/node_modules` technic from each nodered home user ?

---

<div class="post-metadata">

**Author:** ![corso66](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/corso66/32/41143_2.png) [@corso66](https://discourse.nodered.org/u/corso66)\
**Post date:** [7 February 2022 13:20 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/6 "2022-02-07T13:20:47Z")

</div>

> [@To install Node-Red globally or not to](https://discourse.nodered.org/t/to-install-node-red-globally-or-not-to/216/2):
>
> In my personal opinion, the only downside is the inability to run Dave’s excellent update script (if you are running on Linux). smile In truth, for beginners at least, your approach is slightly more complex to start. You do, of course, have to translate many install instructions and other help information as most will assume a standard installation. There is one more disadvantage. You need to create your own startup command. The default installation on Linux at least (certainly on a Raspberr…

I have read this. If i understand, @TotallyInformation make a local install to launch more than one node red instance ?  
A few days ago, (i installed node red localy on a VM from the classic NR precedure), i created a new user, copy all the original .nodered folder into the new home user. And start a new instance with another port. That is running now, but is it proper ?

---

<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:** [7 February 2022 13:40 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/7 "2022-02-07T13:40:26Z")

</div>

> [@corso66](#):
>
> As you say, global install or local install... Everytime i create a new user, i need to install nodered for this user, locally ?

No, not at all. By locally, I mean not using the `-g` option when installing Node-RED. You will install to a standard folder which should be read-only accessible to all users needing to use Node-RED. Each user then has a separate userDir folder that is passed as a parameter to the Node-RED startup for that user.

So, you have an OS user/group for installing Node-RED and separate OS users for each instance. The consuming users need read/execute access to the Node-RED installation folder. But they don't need write access.

Then you can install nodes common to all users in the Node-RED folder and users can't mess with those.

Users can, however, install/uninstall their own nodes as well. If you want to stop that, a different approach is required to prevent the users from accessing their userDir folders directly. That is possible but more complex.

> [@corso66](#):
>
> Create a link that point to the main user folder

You don't actually need that and should avoid it if possible because it leaves you back with the problem of disjointed restarts for each user and would let users install/remove nodes for everyone which is almost certainly not what you want.

---

<div class="post-metadata">

**Author:** ![corso66](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/corso66/32/41143_2.png) [@corso66](https://discourse.nodered.org/u/corso66)\
**Post date:** [7 February 2022 15:54 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/8 "2022-02-07T15:54:09Z")

</div>

> [@TotallyInformation](#):
>
> No, not at all. By locally, I mean not using the `-g` option when installing Node-RED. You will install to a standard folder which should be read-only accessible to all users needing to use Node-RED. Each user then has a separate userDir folder that is passed as a parameter to the Node-RED startup for that user.

Ok that it's clear for me.

> [@TotallyInformation](#):
>
> > [@corso66](#):
> >
> > Create a link that point to the main user folder
> 
> You don't actually need that and should avoid it if possible because it leaves you back with the problem of disjointed restarts for each user and would let users install/remove nodes for everyone which is almost certainly not what you want.

I propose this, only for the `/node_modules`. If i put it in any admin forlder, shared for all users created. And apply to it only read and execute atribute ?  
Also, i will disable the node red interface for users and enable their login/mp in settings.js file.

---

<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:** [7 February 2022 17:42 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/9 "2022-02-07T17:42:42Z")

</div>

> [@corso66](#):
>
> I propose this, only for the `/node_modules` . If i put it in any admin forlder, shared for all users created. And apply to it only read and execute atribute ?

You don't need to do that. Node-RED happily consumes nodes installed along-side Node-RED itself. So no need to mess with sharing a folder.

---

<div class="post-metadata">

**Author:** ![corso66](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/corso66/32/41143_2.png) [@corso66](https://discourse.nodered.org/u/corso66)\
**Post date:** [7 February 2022 19:05 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/10 "2022-02-07T19:05:38Z")

</div>

> [@TotallyInformation](#):
>
> You don't need to do that. Node-RED happily consumes nodes installed along-side Node-RED itself. So no need to mess with sharing a folder.

So ! I create a user with `/home/user/.nodered` directory, i copy settings.js and other config json files to it (without `/node_modules`), i launch node-red command with this path in argument and that all ?

---

<div class="post-metadata">

**Author:** ![corso66](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/corso66/32/41143_2.png) [@corso66](https://discourse.nodered.org/u/corso66)\
**Post date:** [7 February 2022 21:51 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/11 "2022-02-07T21:51:47Z")

</div>

@TotallyInformation

I tryed this :

- First :

I created a new linux user "test", a `/.nodered` folder and copyed to it minimal files without `/node_modules`. Port 1881 in `settings.js`.  
I started instance for this user by : `sudo node-red -u /home/test/.nodered`

A warning said me that many node missing.

Then i created a link that point to the original node\_modules in my nodered home :  
`sudo ln -s /home/me/.nodered/nodes_modules`

That is running well.

- Second :

I created another nodered folder in my user home named `.nodered2` without `/node_modules`.  
Port 1882 in `settings.js`.

It's the same problem, i must to create another symbolic link to `/.nodered/node_modules`  
and this third instance fonction properly.

---

<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:** [7 February 2022 22:20 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/12 "2022-02-07T22:20:53Z")

</div>

1. Make sure that you have Node.js installed.
2. Create a new user `nodered`.
3. switch to that user id and create a convenient folder: `nodered`
4. in that new folder `npm install node-red --production --unsafe-perm`
5. Change the permissions on the nodered folder so that the `nodered` group only has read and execute permissions.
6. Create a new user `fred`
7. add user fred to group `nodered`
8. Create a bash script in fred's home location that runs node-red - something like `node /home/nodered/nodered/node_modules/node-red/red.js`
9. run the script to set up the fred users `.node-red` folder and files then stop node-red
10. Go install some new nodes as user nodered into the ~/nodered folder for that user.
11. Switch back to fred and restart node-red.

Actually, in step 9, once fred has a `~/.node-red` folder, you can add the startup for node-red to that folder's package.json file and you won't need the bash script so you could in fact skip step 8 and just run node-red manually the first time.

Of course, once you have a single user's ~/,node-red folder, you can take a copy and deploy that direct to any new users and so miss out the rest of the steps. Maybe keep a copy in the nodered users home and create a deployment script there.

Note that I've not done this myself and I've not tested these steps but it should be about right.

---

<div class="post-metadata">

**Author:** ![corso66](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/corso66/32/41143_2.png) [@corso66](https://discourse.nodered.org/u/corso66)\
**Post date:** [8 February 2022 22:14 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/13 "2022-02-08T22:14:07Z")

</div>

Thanls for this procedure.

The idea with that, we create only one path with one `node_modules` and all users in the same nodered group access to it with r and x permissions ... that's ok !

I will try it.

But with what i've done, at the end is it the same ? if i apply same permissions ?

---

<div class="post-metadata">

**Author:** ![corso66](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/corso66/32/41143_2.png) [@corso66](https://discourse.nodered.org/u/corso66)\
**Post date:** [10 February 2022 22:51 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/14 "2022-02-10T22:51:36Z")

</div>

> [@TotallyInformation](#):
>
> npm install node-red --production --unsafe-perm

Mmmm the problem is, when i put this install command, only node\_modules & package.json is copied in the /nodered folder...  
And when i try to start from /home/fred/.nodered he say me ☹

```auto
VirtualBox:/home/fred/.node-red$ node-red-start

Node-RED is not yet fully installed. Please re-run the install script again manually.
 
   bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
 
then retry node-red-start

```

Need to install nodered normaly in addition ?

---

<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 February 2022 23:29 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/15 "2022-02-10T23:29:17Z")

</div>

> [@corso66](#):
>
> `node-red-start`

Sorry, I thought you understood that you have to start node-red manually, you can't use the `node-red-start` command. Something like `node node_modules/node-red/red.js`

I put it as the start script in the package.json file and then you only have to do `npm start`.

---

<div class="post-metadata">

**Author:** ![corso66](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/corso66/32/41143_2.png) [@corso66](https://discourse.nodered.org/u/corso66)\
**Post date:** [11 February 2022 10:59 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/16 "2022-02-11T10:59:06Z")

</div>

> [@TotallyInformation](#):
>
> /home/nodered/nodered/node\_modules/node-red/red.js

I'm sorry, i thing i'm arriving to my linux/nodered  
knowledge limits, and to take you to much time ...

This what i've done :

```auto
// install Node.js

// Create a new user "wbsys" and his personnal folder
sudo useradd -m wbsys

// switch to that user id and create a convenient folder in /home/wbsys "/nodered"
su wbsys
cd /home/wbsys
sudo mkdir nodered

// go in "/nodered" folder and install nodered
cd /nodered
sudo npm install node-red --production --unsafe-perm

// verify or change "/nodered" permission with read and execute only
sudo chmod 755 nodered

// create a new group "nodered"
sudo groupadd nodered

// put "/nodered" folder to "nodered" group
sudo chgrp -R nodered /home/wbsys/nodered

// Create a first user "fred", his personnal folder and password
sudo useradd -m fred
sudo passwd fred

// add "fred" user to the "nodered" group
sudo gpasswd -a fred nodered

```

I've created `/.node-red` in fred folder, and put a minimalist package.json and settings.js files into it.

But now, i don't understand how all of that run.  
In this example, i ran start in a bash like this (.sh in `fred` home folder :

```auto
#!/usr/bin/bash
/home/wbsys/nodered/node_modules/node-red/red.js
echo "ok"

```

Nodered response :

```auto
fred@sylvain-VirtualBox:~$ ./start.sh
11 Feb 11:49:24 - [error] Failed to start server:
11 Feb 11:49:24 - [error] Error: EACCES: permission denied, mkdir '/home/fred/.node-red/node_modules'

```

I don't understand how nodered can reach `/wbsys/nodered/node_modules` even if `fred` is in the `nodered` group.

Here my /etc/group :

```auto
test:x:1001:test
wbsys:x:1002:
nodered:x:1004:fred
fred:x:1003:

```

🤯

---

<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:** [11 February 2022 11:53 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/17 "2022-02-11T11:53:04Z")

</div>

> [@corso66](#):
>
> But now, i don't understand how all of that run.

As user fred, run `node /home/wbsys/nodered/node_modules/node-red/red.js` manually 1 time, that should update the package.json and create all of the other files needed. And add that command as the "start" script to the package.json file in fred's ~/.node-red folder. Then to start node-red for fred in the future, `cd ~/.node-red && npm start`. Your other script is OK, it just needs the `node ` at the start to tell node.js to start the actual red.js script. You could, of course, instead change the `#!` line to reference your installation of node.js, then you wouldn't need the leading `node `.

---

<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:** [11 February 2022 11:58 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/18 "2022-02-11T11:58:36Z")

</div>

> [@corso66](#):
>
> I don't understand how nodered can reach `/wbsys/nodered/node_modules` even if `fred` is in the `nodered` group.

You didn't apply the permissions change to sub-folders when you changed them.

---

<div class="post-metadata">

**Author:** ![corso66](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/corso66/32/41143_2.png) [@corso66](https://discourse.nodered.org/u/corso66)\
**Post date:** [11 February 2022 13:42 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/19 "2022-02-11T13:42:11Z")

</div>

I think, perhaps, that i see the end of the tunnel...

I had this error :

```auto
fred@sylvain-VirtualBox:~/.node-red$ node /home/wbsys/nodered/node_modules/node-red/red.js
internal/fs/utils.js:332
    throw err;
    ^

Error: EACCES: permission denied, copyfile '/home/wbsys/nodered/node_modules/node-red/settings.js' -> '/home/fred/.node-red/settings.js'
    at Object.copyFileSync (fs.js:2061:3)
    at copyFile (/home/wbsys/nodered/node_modules/fs-extra/lib/copy-sync/copy-sync.js:70:6)
    at onFile (/home/wbsys/nodered/node_modules/fs-extra/lib/copy-sync/copy-sync.js:56:25)
    at getStats (/home/wbsys/nodered/node_modules/fs-extra/lib/copy-sync/copy-sync.js:48:44)
    at handleFilterAndCopy (/home/wbsys/nodered/node_modules/fs-extra/lib/copy-sync/copy-sync.js:33:10)
    at Object.copySync (/home/wbsys/nodered/node_modules/fs-extra/lib/copy-sync/copy-sync.js:26:10)
    at Object.<anonymous> (/home/wbsys/nodered/node_modules/node-red/red.js:125:20)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32) {
  errno: -13,
  syscall: 'copyfile',
  code: 'EACCES',
  path: '/home/wbsys/nodered/node_modules/node-red/settings.js',
  dest: '/home/fred/.node-red/settings.js'

```

Fix it with  
`wbsys@sylvain-VirtualBox:/home/fred$ sudo chmod 777 .node-red/`

YES ! node-red started with your command :  
`node /home/wbsys/nodered/node_modules/node-red/red.js`

```auto
Welcome to Node-RED
===================

11 Feb 14:20:57 - [info] Node-RED version: v2.2.0
11 Feb 14:20:57 - [info] Node.js version: v14.19.0
11 Feb 14:20:57 - [info] Linux 5.4.0-99-generic x64 LE
11 Feb 14:20:58 - [info] Loading palette nodes
11 Feb 14:20:59 - [info] Settings file : /home/fred/.node-red/settings.js
11 Feb 14:20:59 - [info] Context store : 'default' [module=memory]
11 Feb 14:20:59 - [info] User directory : /home/fred/.node-red
11 Feb 14:20:59 - [warn] Projects disabled : editorTheme.projects.enabled=false
11 Feb 14:20:59 - [info] Flows file : /home/fred/.node-red/flows.json
11 Feb 14:20:59 - [info] Creating new flow file
11 Feb 14:20:59 - [warn] 

---------------------------------------------------------------------
patatipatata
---------------------------------------------------------------------

11 Feb 14:20:59 - [info] Server now running at http://127.0.0.1:1880/
11 Feb 14:20:59 - [info] Starting flows
11 Feb 14:20:59 - [info] Started flows

```

I have these new files in .node-red as you said, and `node_module` is empty so, i suppose all is running, the "link" from fred is effective ??

---

<div class="post-metadata">

**Author:** ![corso66](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/corso66/32/41143_2.png) [@corso66](https://discourse.nodered.org/u/corso66)\
**Post date:** [11 February 2022 13:50 UTC](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882/20 "2022-02-11T13:50:59Z")

</div>

Mmmm... but when i use the palete for install the dashboard, `node_modules` in fred get the dashboard installation...

[Next page](https://discourse.nodered.org/t/shared-system-folders-in-multi-user-instances/57882.md?page=2)
