Node red error: permission denied when installing package from palette

Got node red project successfully running in docker. However, can't install new packages from palette because of file permissions.

For example:

-----------------------------------------------------------
2024-09-09T10:31:28.887Z Install : postgrestor 0.0.2

2024-09-09T10:31:28.912Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --omit=dev --engine-strict postgrestor@0.0.2
2024-09-09T10:31:34.092Z [err] npm error code EACCES
2024-09-09T10:31:34.092Z [err] npm error syscall rename
2024-09-09T10:31:34.092Z [err] npm error path /data/node_modules/@openp4nr/modbus-serial
2024-09-09T10:31:34.092Z [err] npm error dest /data/node_modules/@openp4nr/.modbus-serial-S75OrEXy
2024-09-09T10:31:34.093Z [err] npm error errno -13
2024-09-09T10:31:34.093Z [err] npm error Error: EACCES: permission denied, rename '/data/node_modules/@openp4nr/modbus-serial' -> '/data/node_modules/@openp4nr/.modbus-serial-S75OrEXy'
2024-09-09T10:31:34.093Z [err] npm error     at async Object.rename (node:internal/fs/promises:782:10)
2024-09-09T10:31:34.093Z [err] npm error     at async moveFile (/usr/local/lib/node_modules/npm/node_modules/@npmcli/fs/lib/move-file.js:30:5)
2024-09-09T10:31:34.093Z [err] npm error     at async Promise.allSettled (index 16)
2024-09-09T10:31:34.093Z [err] npm error     at async [reifyPackages] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:325:11)
2024-09-09T10:31:34.093Z [err] npm error     at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:142:5)
2024-09-09T10:31:34.093Z [err] npm error     at async Install.exec (/usr/local/lib/node_modules/npm/lib/commands/install.js:150:5)
2024-09-09T10:31:34.093Z [err] npm error     at async Npm.exec (/usr/local/lib/node_modules/npm/lib/npm.js:207:9)
2024-09-09T10:31:34.093Z [err] npm error     at async module.exports (/usr/local/lib/node_modules/npm/lib/cli/entry.js:74:5) {
2024-09-09T10:31:34.093Z [err] npm error   errno: -13,
2024-09-09T10:31:34.093Z [err] npm error   code: 'EACCES',
2024-09-09T10:31:34.093Z [err] npm error   syscall: 'rename',
2024-09-09T10:31:34.093Z [err] npm error   path: '/data/node_modules/@openp4nr/modbus-serial',
2024-09-09T10:31:34.093Z [err] npm error   dest: '/data/node_modules/@openp4nr/.modbus-serial-S75OrEXy'
2024-09-09T10:31:34.093Z [err] npm error }
2024-09-09T10:31:34.093Z [err] npm error
2024-09-09T10:31:34.093Z [err] npm error The operation was rejected by your operating system.
2024-09-09T10:31:34.093Z [err] npm error It is likely you do not have the permissions to access this file as the current user
2024-09-09T10:31:34.093Z [err] npm error
2024-09-09T10:31:34.093Z [err] npm error If you believe this might be a permissions issue, please double-check the
2024-09-09T10:31:34.093Z [err] npm error permissions of the file and its containing directories, or try running
2024-09-09T10:31:34.093Z [err] npm error the command again as root/Administrator.
2024-09-09T10:31:34.096Z [err] npm error A complete log of this run can be found in: /data/.npm/_logs/2024-09-09T10_31_28_982Z-debug-0.log
2024-09-09T10:31:34.103Z rc=243

Then I tried setting all rights multiple places in Dockerfile. Which seems to have effect on the parent folder.

But taking this specific folder in log file from example, I can't rename it and it contains files with more restrictive permissions.

/data/node_modules/@openp4nr/modbus-serial $ ls -l
total 88
-rw-r--r--    1 node-red node-red       759 Sep  2 14:26 LICENSE
-rw-r--r--    1 node-red node-red      6115 Sep  2 14:26 ModbusRTU.d.ts
-rw-r--r--    1 node-red node-red      9860 Sep  2 14:26 README.md
-rw-r--r--    1 node-red node-red      2780 Sep  2 14:26 ServerTCP.d.ts
-rw-r--r--    1 node-red node-red       245 Sep  2 14:26 TestPort.d.ts
drwxrwxrwx    1 root     root           512 Sep  3 10:52 apis
drwxrwxrwx    1 root     root           512 Sep  3 10:52 examples
-rw-r--r--    1 node-red node-red      1391 Sep  2 14:26 gulpfile.js
-rw-r--r--    1 node-red node-red        94 Sep  2 14:26 index.d.ts
-rw-r--r--    1 node-red node-red     47665 Sep  2 14:26 index.js
drwxrwxrwx    1 root     root           512 Sep  3 10:52 node_modules
-rwxr-xr-x    1 node-red node-red        47 Sep  2 14:26 npm-update.sh
-rwxr-xr-x    1 node-red node-red        67 Sep  2 14:26 npm-upgrade.sh
-rw-r--r--    1 node-red node-red       501 Sep  2 14:26 overwriteRegistryConfigForHotfix.js
-rw-r--r--    1 node-red node-red      1236 Sep  2 14:26 package.json
drwxrwxrwx    1 root     root           512 Sep  3 10:52 ports
drwxrwxrwx    1 root     root           512 Sep  3 10:52 servers
drwxrwxrwx    1 root     root           512 Sep  3 10:52 test
drwxrwxrwx    1 root     root           512 Sep  3 10:52 utils
drwxrwxrwx    1 root     root           512 Sep  3 10:52 worker

I wonder if the default Dockerfile sets limited permissions for security reasons? But I'd like to let user add new packages from palette anyway.

Now I could log in as root (exec in docker) and overwrite permissions manually. But prefer to solve this permanently in the Dockerfile.

Suggestions?

Turns out even root can't rename this folder. And I can't rename it in windows explorer either (used by another program).

Not sure what happened but problem was solved by "npm i" on the physical project folder in windows.

I sometimes get the same kind of issues with certain nodes.

Generally, I use the command line to manually delete the folder that starts with the dot and ends in the random string. '/data/node_modules/@openp4nr/.modbus-serial-S75OrEXy'.

I believe that will have installed the nodes using the current windows build tools, rather than the build tools in the container. Possibly that will not be a problem, but I believe that it could be. For example, you might have different versions of the compiler or nodejs installed in docker and in Windows. I don't use Windows though, so I may be wrong.

Docker on windows or linux variant?
Node-red container runs as user with uid 1000 in the container. (unless you specify a user in your docker-compose.yml.)
you should provide a user with the same uid on the docker host, and assign required rights to that user on your bindmounted directory.
This works on my ubuntu based docker server, no idea how to do that on windows based docker.

I've seen the related issue, where a few packages could not be removed using the Palette Manager when running Node-RED in Docker Desktop on Windows. This needed npm running on Windows to uninstall the package.

This problem can be avoided by not binding the /data folder to a Windows folder, but instead letting it use a WSL folder. Which might not always be a good option.

Thanks all. Yeah probably was some inconsistencies between package.json and packages actually installed in node_modules. This was docker desktop running on windows. By using npm -i it probably cleaned up and synchronized everything according to package.json, and problem disappeared.

1 Like

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