Adding a persistent value to $ PATH on Raspbian
I'm a Linux newbie, so I'm sorry I have a newbie question, but after about an hour I'm trying to add Node.js to $ PATH with no luck :(
I used the following line to add Node
PATH=$PATH:node-v0.10.24-linux-arm-armv6j-vfp-hard/bin
it worked, but when I logged out of the terminal and logged in again, the path disappeared.
Later I tried to add the same line to .profile
, .logins.defs
and .bashrc
. Everything didn't work, so I removed the line.
Please help me with this!
PS when I added the line to .profile
I was able to call Node, but when I changed my directory to go to the Node project directory I got the following error:
-bash: node-v0.10.24-linux-arm-armv6j-vfp-hard/bin/node: No such file or directory
source to share
You must add an absolute path, not a relative one. You add it to your path: node-v0.10.24-linux-arm-armv6j-vfp-hard/bin
. This is a relative path, not an absolute path (absolute paths start with /
). You can change your line to:
PATH=$PATH:DIR/node-v0.10.24-linux-arm-armv6j-vfp-hard/bin
where DIR
is the full path to the directory containing node-v0.10.24-linux-arm-armv6j-vfp-hard
.
It will probably be helpful for you to read a little about how it all works - it's not that hard once you see it explained. See https://superuser.com/questions/238987/how-does-unix-search-for-executable-files .
source to share
You have $ HOME already installed in your home directory.
So, you can use this in your .profile:
PATH="$PATH:$HOME:$HOME/bin:$HOME/node-v0.10.24-linux-arm-arββmv6j-vfp-hard/bin"
If you set it as an absolute path, you will not be able to copy this .profile to another user who is configured similarly.
I see there is another question that has to do with installing node.js on Debian - and I must admit I'm surprised it is installed for every user. So if you install for a different login, you can copy your .profile to the new login to fix this problem. There will be no need to edit for each user if you use the $ HOME variable like this. Just a simple copy, cut and paste.
For reference, there is another question / answer here: install node.js on debian
source to share