Unable to create another node-red instance

I followed the above :point_up: post. and using the below :point_down: command to create another Node-RED instance.

node-red -u /node-red-1881 -p 1881

But got an error :point_down:

node:internal/fs/utils:347
throw err;
^

Error: EACCES: permission denied, mkdir '/node-red-1881'
at Object.mkdirSync (node:fs:1382:3)
at module.exports.makeDirSync (/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/mkdirs/make-dir.js:23:13)
at handleFilterAndCopy (/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/copy/copy-sync.js:35:35)
at Object.copySync (/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/copy/copy-sync.js:29:10)
at Object. (/usr/lib/node_modules/node-red/red.js:129:20)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
errno: -13,
syscall: 'mkdir',
code: 'EACCES',
path: '/node-red-1881'
}

So I googled and found several links one of which is this LINK
which said run this to fix

$ sudo npm install --unsafe-perm=true --allow-root

but no resolve then I googled some more and did the following

  1. npm cache clean :frowning: (got error :point_down:)

npm ERR! As of npm@5, the npm cache self-heals from corruption issues
npm ERR! by treating integrity mismatches as cache misses. As a result,
npm ERR! data extracted from the cache is guaranteed to be valid. If you
npm ERR! want to make sure everything is consistent, use npm cache verify
npm ERR! instead. Deleting the cache can only make npm go slower, and is
npm ERR! not likely to correct any problems you may be encountering!
npm ERR!
npm ERR! On the other hand, if you're debugging an issue with the installer,
npm ERR! or race conditions that depend on the timing of writing to an empty
npm ERR! cache, you can use npm install --cache /tmp/empty-cache to use a
npm ERR! temporary cache instead of nuking the actual one.
npm ERR!
npm ERR! If you're sure you want to delete the entire cache, rerun this command
npm ERR! with --force.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/scada/.npm/_logs/2022-12-09T05_16_12_216Z-debug-0.log

  1. npm cache clean --force
  2. sudo npm install -g npm
  3. npm install :frowning: (got error again :point_down:)

npm ERR! code EACCES
npm ERR! syscall open
npm ERR! path /home/scada/package-lock.json
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, open '/home/scada/package-lock.json'
npm ERR! [Error: EACCES: permission denied, open '/home/scada/package-lock.json'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'open',
npm ERR! path: '/home/scada/package-lock.json'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/scada/.npm/_logs/2022-12-09T05_18_00_905Z-debug-0.log

Can anyone help me on this. :weary: I've no idea how to solve this.

Your issue is simple & clearly described. The account you are using does not have permission to create the directory /node-red-1881

Try

sudo mkdir /node-red-1881
sudo chown $USER /node-red-1881
node-red -u /node-red-1881 -p 1881

Note.
If you intend on creating multiple node reds, then I'd recommend creating a parent directory, taking ownership of that directory, then all subsequent instances will just work without having to take ownership.

For example...

sudo mkdir /node-reds
sudo chown $USER /node-reds
node-red -u /node-reds/node-red-1881 -p 1881
node-red -u /node-reds/node-red-1882 -p 1882
node-red -u /node-reds/node-red-1884 -p 1884

thankyou so much :+1:

need to ask one more thing. to have these instances auto started.

I need to edit nodered.service files present in locations :

/etc/systemd/system/multi-user.target.wants
/lib/systemd/system

edit lines -
existing
EnvironmentFile=-/home/scada/.node-red/EnvironmentFile
and adding below (referred link):
EnvironmentFile=-/node-reds/node-red-1881/EnvironmentFile
EnvironmentFile=-/node-reds/node-red-1882/EnvironmentFile
EnvironmentFile=-/node-reds/node-red-1883/EnvironmentFile (avoiding 1883 instance as suggested in the post)
EnvironmentFile=-/node-reds/node-red-1884/EnvironmentFile
EnvironmentFile=-/node-reds/node-red-1885/EnvironmentFile

Is this correct? Or is there any other way?

No, create a service for each node-red instance.

There are some alternative options listed in the docs: Starting Node-RED on boot : Node-RED

Otherwise search the internet on how to make and enable a service for your particular operating system.

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