0

I've a dedicated vps running on cent os. I installed node on that by using

yum install nodejs

It installed successfully without any error and it shows version also.

node -v
v10.16.0

But it shows an error while running this with sudo

sudo node
Command not found

And when I try to run npm with sudo it shows

sudo npm
/usr/bin/env: node: No such file or directory

I tried many solutions from here like

ln -s /usr/bin/nodejs /usr/bin/node

and many more. I've also tried reinstalling node but still no luck.

Arman Khan
  • 55
  • 2
  • 8
  • Here's another post with the same [issue](https://stackoverflow.com/a/5062718/4054878). The accepted answer however is a workaround. – Ntokozo Zwane Jun 11 '19 at 12:38
  • @NtokozoZwane I've already tried that solution but still no luck. – Arman Khan Jun 11 '19 at 12:40
  • sudo does not preserve your $PATH environment variable for security reasons. The command you want to run (node or npm) in your own user's shell using process substitution with which. sudo "$(which npm)" install express or sudo "$(which node)" bin/www – Laakal Jun 11 '19 at 13:17

0 Answers0