Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

/usr/bin/node : Permission denied

On Ubuntu 16.04, I have installed NodeJS v8.9.3, using NVM. I ran the installation as root, and so node was installed here:

/root/.nvm/versions/node/v8.9.3/bin/node

In the hope of making it accessible to non-root users, I created a soft link at /usr/bin/node:

lrwxrwxrwx 1 root root      40 янв 18 11:58 node -> /root/.nvm/versions/node/v8.9.3/bin/node

The node file itself has executable permissions for all users:

-rwxrwxr-x 1 500 500 35200878 дек  8 17:09 /root/.nvm/versions/node/v8.9.3/bin/node

When I access node as root, all works perfectly:

# node -v && which node
v8.9.3
/root/.nvm/versions/node/v8.9.3/bin/node

Any attempt to access it as a non-root user fails:

$ node -v
The program 'node' is currently not installed. You can install it by typing:
sudo apt install nodejs-legacy
$ /usr/bin/node -v
bash: /usr/bin/node: Permission denied

What changes do I have to make where to allow non-root users access to node?

like image 853
James Newton Avatar asked Dec 20 '25 04:12

James Newton


1 Answers

I would suggest you remove your current installation and install using apt-get instead. Here is tutorial from official Ubuntu website: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

That way of installing will make node accessible for root as well as all other users by default.

Also, keep in mind that:

Because of a conflict with another package, the executable from the Ubuntu repositories is called nodejs instead of node. Keep this in mind as you are running software.

Here is another good resource on installing nodejs: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04

like image 51
Ryan Tapel Avatar answered Dec 21 '25 19:12

Ryan Tapel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!