I have set path correctly just like before but I am getting command not found error.

$echo $PATH

So I have to run node using full path for every run and it always gives error of Permission denied when run without sudo:

$sudo /usr/local/bin/node ***

Does anyone know what the issue is?


Shorten your $PATH from /usr/local/bin/node to /usr/local/bin.

The $PATH variable is for storing the names of directories which contain executables; it's not for storing any names of executables within those directories. The file command will show the difference:

file /usr/local/bin /usr/local/bin/node

The sudo trouble probably means that the current user lacks permission to run node. Check permission and ownership:

stat --printf="%a %G:%U\n" /usr/local/bin/node

It should say something like:

777  root:root

Suppose it doesn't, but there's another file foo in usr/local/bin/ that works every time, and has the correct permissions and ownership. To give node the same permissions and ownership as foo:

sudo chown --reference=/usr/local/bin/foo /usr/local/bin/node
sudo chmod --reference=/usr/local/bin/foo /usr/local/bin/node
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.