Closed
Description
NPM seems to have changed the way it runs scripts, see npm/cli#4811, which causes node-red to not be executed with the user that you expect.
What are the steps to reproduce?
root@debian:~# rm -rf nrdata/; docker run -it --rm -u root -p 1880:1880 -v $(pwd)/nrdata:/data --name nodered nodered/node-red:3.0.0
What happens?
> [email protected] start
> node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"
node:internal/fs/utils:345
throw err;
^
Error: EACCES: permission denied, copyfile '/usr/src/node-red/node_modules/node-red/settings.js' -> '/data/settings.js'
at Object.copyFileSync (node:fs:2817:3)
at copyFile (/usr/src/node-red/node_modules/fs-extra/lib/copy/copy-sync.js:73:6)
at onFile (/usr/src/node-red/node_modules/fs-extra/lib/copy/copy-sync.js:59:25)
at getStats (/usr/src/node-red/node_modules/fs-extra/lib/copy/copy-sync.js:51:44)
at handleFilterAndCopy (/usr/src/node-red/node_modules/fs-extra/lib/copy/copy-sync.js:36:10)
at Object.copySync (/usr/src/node-red/node_modules/fs-extra/lib/copy/copy-sync.js:29:10)
at Object.<anonymous> (/usr/src/node-red/node_modules/node-red/red.js:129:20)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32) {
errno: -13,
syscall: 'copyfile',
code: 'EACCES',
path: '/usr/src/node-red/node_modules/node-red/settings.js',
dest: '/data/settings.js'
}
You can verify this is due to npm by running the script directly through node
root@debian:~# rm -rf nrdata/; docker run -it --rm -u root --entrypoint /bin/bash -p 1880:1880 -v $(pwd)/nrdata:/data --name nodered nodered/node-red:3.0.0
bash-5.1# node node_modules/node-red/red.js
which works as expected.
What do you expect to happen?
I expect this to work as before with 2.x.
root@debian:~# rm -rf nrdata/; docker run -it --rm -u root -p 1880:1880 -v $(pwd)/nrdata:/data --name nodered nodered/node-red:2.2.2
> [email protected] start /usr/src/node-red
> node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"
18 Jul 22:09:40 - [info]
Welcome to Node-RED
===================
...
Please tell us about your environment:
Platform/OS: Debian 11 64bit