Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k points)

I have just installed nodejs on a new EC2 micro instance.

I installed it normally, ./configure -> make -> sudo make install.

Problem: When I run "node" under ec2-user, it runs perfectly. When I run "sudo node", it fails.

I found out that node is in:

[[email protected] ~]$ whereis node

node: /usr/local/bin/node /usr/local/lib/node

and the current path is

[[email protected] ~]$ echo $PATH


but, the sudo path is

[[email protected] ~]# echo $PATH


then I tried to edit the root PATH to include the paths to node, so "node" runs when I'm logged in as root - but it still won't work when I log in as ec2-user and run "sudo node".

I need this to install npm properly. Any idea on how to include the node path while running "sudo node"?

1 Answer

0 votes
by (44.3k points)

This can be fixed with some links, I will mention them below.

sudo ln -s /usr/local/bin/node /usr/bin/node

sudo ln -s /usr/local/lib/node /usr/lib/node

sudo ln -s /usr/local/bin/npm /usr/bin/npm

sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

Browse Categories