env variable

hi

i would like to run node js in console witouhout to type all the path…

so i .bashrc i wrote


export NODEJS=/home/collinm/Development/compiler/node-v6.9.5-linux-x64/bin/node

but in console

node continue to be unknown…

tried to put in .profile

but get same result…

thanks

Export creates an environment variable - not an alias nor does it add the command to the path.

What you want is to append your $PATH variable with your NODEJS binary path or create an alias, so for example;

alias nodejs="/home/collinm/Development/compiler/node-v6.9.5-linux-x64/bin/node"
or
export PATH="$PATH:/home/collinm/Development/compiler/node-v6.9.5-linux-x64/bin/"

Both are only valid for the duration of your shell so you need to add them to your .bashrc - the latter adding all the commands available under the path bin so they are executable anywhere, by your current user.

Additional info:

An alias (personally would prefer this solution) is best put in ~/.alias (create it when not already there).

When adding to your PATH in .bashrc, be prepaired for the following phenomenon.
Every start of bash uses .bashrc. Thus starting a child bash process from a process tree where there is already a bash process will traverse .bashrc twice (or more). And that will add your directory twice or more. While this will not break the way it works, it nevertheless might not be what you expect. You could use .profile instead, which is only called on a login shell. But again, in this case, I would prefer the alias method.

BTW, when you want to call it with

node

you alias should be

alias node="/home/collinm/Development/compiler/node-v6.9.5-linux-x64/bin/node"

Miuku’s example would make you to use

nodejs

to call it.