alias of nodejs as node on 14.04

48

Solution 1

Recently fixed this using nodejs-legacy.

Run the following command:

sudo apt-get install nodejs-legacy

This should fix it.

Solution 2

Well curiously, I have a node. It's an alternatives system symlink and I'm not quite sure how I got it (in a way that you don't). It was a while since I installed it so perhaps I followed this SO post or one like it... Who knows!

You could just write a little bash alias but that'll only work for one user at a time. It might just make more sense to add it as as symlink globally. I'm not sure there's any value going through the alternatives system so we can just plonk one in /usr/local/bin (this is where non-package-managed binaries should go):

sudo ln -s /usr/local/bin/nodejs /usr/bin/node

Edit: That SO post I talked about actually links back to one of ours which might be relevant. It suggests installing nodejs-legacy is the way forward.

Share:
48

Related videos on Youtube

gbenga wale
Author by

gbenga wale

Updated on September 18, 2022

Comments

  • gbenga wale
    gbenga wale over 1 year

    I have a form which is used to insert records into the database and if all goes right redirect the user to the index page with a message (actually set with a session) about the success or failure of the operation.

    Now, am able to set the session in add_book.php and display the message in index.php but the message still persist after reloading the page without going away.

    in add_book.php. I have this

    $_SESSION['insert'] = "Record inserted into the database";
                            session_regenerate_id();
                            session_write_close();
                            echo '...succesfully add new book...';
                            header("Location: index.php");
                            exit();  
    

    and in the index.php, I have this

    <?php if(isset($_SESSION['insert'])){
    ?>
    <p class="update"><?php echo $_SESSION['insert'];?></p>
    <?php
    }//end of isset $_SESSION['insert']
    ?>
    
    • PradyJord
      PradyJord almost 10 years
      Please add the same alias in /etc/profile and restart; after changing any rc file or profile file you must source it.
    • codeofnode
      codeofnode almost 10 years
      @Jord i edited /etc/profile with same alias and restarted. But still the problem is same.
    • John N
      John N over 7 years
      Several years late, but... aliases won't (normally) work in a non-interactive shell: stackoverflow.com/a/1615973/7222080 Follow the symlink advice in the answers.
    • Roy Bogado
      Roy Bogado over 6 years
      session_start() maybe?
    • The Codesee
      The Codesee over 6 years
      Have you tried unsetting the session?
    • Patrick Q
      Patrick Q over 6 years
      Well, what exactly are you doing to remove the message from the session? It doesn't just go away by itself.
    • gbenga wale
      gbenga wale over 6 years
      session is started already
    • Rotimi
      Rotimi over 6 years
      are you using unset() to remove the session? or perhaps setting it to null?
    • gbenga wale
      gbenga wale over 6 years
      @patrick I think isset should do the job after it is redirect but after reloading, it should disappear since nothing is set again
    • Patrick Q
      Patrick Q over 6 years
      Once something is set in a session, it stays until removed or the session is destroyed. It doesn't just go away because you loaded a new page.
    • gbenga wale
      gbenga wale over 6 years
      @tunde no. didnt do that
    • Rotimi
      Rotimi over 6 years
      doesn't @Manikiran solution solve your issue?
    • gbenga wale
      gbenga wale over 6 years
      @patrick then the unsetting will be inside else statement
    • Patrick Q
      Patrick Q over 6 years
      You should really go back and review the basics of sessions and if/else logic. You are severely misunderstanding how all this stuff works.
    • Rotimi
      Rotimi over 6 years
      you do not need an else statement. Once the insert key exists in the session, echo it then on the next line unset() it. Simple
  • srcspider
    srcspider about 9 years
    Find the location of nodejs via whereis nodejs then do ln -s /usr/bin/nodejs ~/bin/node (yes, no sudo there); replace /usr/bin/nodejs with the path your nodejs is at
  • srcspider
    srcspider about 9 years
    going backwards is not the way forward