Results 1 to 3 of 3

Thread: env variable

  1. #1
    Join Date
    Jun 2008
    Location
    Canada
    Posts
    436

    Default env variable

    hi

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

    so i .bashrc i wrote

    Code:
    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
    www.laboiteaprog.com

  2. #2
    Join Date
    May 2012
    Location
    Finland
    Posts
    2,004

    Default Re: env variable

    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.
    .: miuku #suse @ irc.freenode.net
    :: miuku@opensuse.org

    .: h​ttps://download.opensuse.org/repositories/home:/Miuku/

  3. #3
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,987

    Default Re: env variable

    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
    Code:
    node
    you alias should be
    Code:
    alias node="/home/collinm/Development/compiler/node-v6.9.5-linux-x64/bin/node"
    Miuku's example would make you to use
    Code:
    nodejs
    to call it.
    Last edited by hcvv; 26-Apr-2017 at 00:59.
    Henk van Velden

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •