npm install requires the user to login as root if using /root directory. Cannot sudo to root.
Issue description
Expected behavior
Execute npm install in /root/ot-node directory as a sudo user and successfully complete the command.
Actual behavior
At some point the sudo privilege is dropped and the user becomes a regular user and can no longer write/access to the root directory. It does work within the regular users homedir.
Steps to reproduce the problem
- Login as regular user and sudo -i to root.
- cd ot-node
- npm install
Specifications
- Node version:
- Platform:
- Node wallet:
- Node libp2p identity:
Contact details
- Email:
Error logs
root@otnode-2:~/ot-node# npm install
> [email protected] install /root/ot-node/node_modules/bufferutil
> node-gyp-build
sh: 1: node-gyp-build: Permission denied
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! [email protected] install: `node-gyp-build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-01-06T16_51_23_165Z-debug.log
Disclaimer
Please be aware that the issue reported on a public repository allows everyone to see your node logs, node details, and contact details. If you have any sensitive information, feel free to share it by sending an email to [email protected].
Pushed a fix here: https://github.com/OriginTrail/ot-node/pull/1739
Should work.
Or just run npm config set unsafe-perm true before running npm install
More info on my setup:
npm -v
8.3.1
node -v
v16.14.0
On older version of node / npm it may not fix the problem since the command into the install script was run AFTER npm install.
Now with newer version, it is run BEFORE so it can fix the problem.
Either way, I still recommand to block root login on server and run docker rootless + secure user.
This issue is being closed as inactive due to the date of the last activity on it. If you believe this is still a problem, please create a new issue and confirm that it is reproducible in the current ot-node release version. We are working towards closing open issues that meet specific criteria and ask you to create a new one for those that that are truly bugs in current release. We'll be monitoring those issues so that they are properly managed.
Thank you, OriginTrail Team