dkg-engine icon indicating copy to clipboard operation
dkg-engine copied to clipboard

npm install requires the user to login as root if using /root directory. Cannot sudo to root.

Open calr0x opened this issue 4 years ago • 2 comments

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

  1. Login as regular user and sudo -i to root.
  2. cd ot-node
  3. 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].

calr0x avatar Jan 06 '22 16:01 calr0x

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

Y0lan avatar Feb 09 '22 14:02 Y0lan

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.

Y0lan avatar Feb 09 '22 14:02 Y0lan

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

NZT48 avatar Dec 26 '22 16:12 NZT48