Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Programming»Nodejs»How to Upgrade Node.js via NPM

    How to Upgrade Node.js via NPM

    By RahulSeptember 21, 20202 Mins Read

    NPM is a package manager for nodejs and many other languages. Currently, I was running nodejs version v5.4.0 on my system. I was in required to install Latest nodejs package on my system. After searching I found the best and easier way to Upgrade Node.js version using NPM quickly. It works perfectly for me and hopes so for you.

    Advertisement
    • How to Install Multiple Node.js Versions via NVM

    Steps to Upgrade Node.Js

    Use the following steps to install or upgrade node.js to latest available version.

    • Current NodeJs Version – First check current nodejs version on your system using following command. In my case it is v5.4.0.
      node -v 
      
      v5.4.0
      
    • Clean Cache Forcefully – Now clean all npm cache from your system forcefully.
      sudo npm cache clean -f 
      
      npm WARN using --force I sure hope you know what you are doing.
      
    • Install n Module – After cleaning all cache from your system, now install n modules using npm command.
      sudo npm install -g n 
      
      /root/.npm-global/bin/n -> /root/.npm-global/lib/node_modules/n/bin/n
      + [email protected]
      
    • Install Nodejs – Let’s install or update latest nodejs version on your system using n module.
      sudo n lts 
      
        installing : node-v12.18.4
             mkdir : /usr/local/n/versions/node/12.18.4
             fetch : https://nodejs.org/dist/v12.18.4/node-v12.18.4-linux-x64.tar.xz
         installed : v12.18.4 (with npm 6.14.6)
      
    • Setup Binary Link - Now link your node binary with latest nodejs installed binary file using following command.
      sudo ln -sf /usr/local/n/versions/node/12.18.4/bin/node /usr/bin/node 
      
    • Check Nodejs Version - Finally recheck your nodejs version. You will find that it showing latest version on your system.
      node -v 
      
      v12.18.4
      

    node.js NodeJs npm upgrade nodejs
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Error: EACCES: permission denied, scandir (Resolved)

    How to list all collections in MongoDB database

    How to Install Grunt on Ubuntu 22.04 & 20.04

    View 45 Comments

    45 Comments

    1. joe on October 25, 2021 9:23 pm

      Hi, Having an issue here.
      sudo n lts
      appears to work correctly
      installing : node-v14.18.1 …
      It told me it changed location…
      old : /usr/bin/node
      new : /usr/local/bin/node
      But now I don’t have node.
      node -v
      bash: /usr/bin/node: No such file or directory

      Thank you for any advice

      Reply
    2. Ras on May 17, 2020 5:32 pm

      Thank you very much its working.

      Reply
    3. MissLamer on February 5, 2020 10:56 am

      great post! thanks a lot 😀

      Reply
    4. Sergey on January 14, 2020 10:56 am

      Thanks! All works!

      Reply
    5. itOne on October 26, 2019 4:43 am

      thanks

      Reply
    6. A Dev on August 29, 2019 7:28 pm

      Regards from Brazil, thanks!

      Reply
    7. BJ on June 22, 2019 2:44 pm

      Thanks, it worked at Fedora 28

      Reply
    8. Isabelle on June 3, 2019 9:54 am

      Hi, thanks for this tutorial!

      I had to do : $ NODE_MIRROR=http://nodejs.org/dist/ n –lts instead of : $ sudo n stable.

      At the end, I did : $ sudo ln -sf /usr/local/n/versions/node/10.16.0/bin/node /usr/bin/node.

      When I check the version, I have this message : bash /usr/bin/node no such file or directory.

      Thanks for your answer.

      Reply
    9. Adam on May 23, 2019 10:00 am

      You saved my life, mister!

      Reply
    10. Jone Quest on May 20, 2019 11:49 pm

      I updated to node 12.2.0, however when I run “node -v”, still shows the previous version. And the command “sudo ln -sf /usr/local/n/versions/node/12.2.0/bin/node /usr/bin/node” doesn’t help.

      Reply
      • Rahul on May 21, 2019 6:44 am

        Jone, First check which node binary is default executed…

        $ which node
        

        Then you can symlink /usr/local/n/versions/node/12.2.0/bin/node to that binary file.

        Reply
    11. Ankit Chouhan on May 15, 2019 4:50 am

      Thanks, it worked.

      Reply
    12. rowing0914 on April 12, 2019 12:34 pm

      not working on ubuntu 16.04 LTS… come on

      Reply
    13. Josh on March 29, 2019 1:59 am

      Doesn’t work on Fedora

      Reply
    14. Isolde on March 20, 2019 8:33 pm

      Very clear instructions, thank you 🙂

      Reply
    15. Guilherme on February 26, 2019 4:29 am

      Great!!!! Bravo!

      Reply
    16. Ahmad Asadi on February 21, 2019 11:43 pm

      You are Awesome bro

      Reply
    17. nilesh on February 1, 2019 8:14 am

      executed all steps without any single error but version is still as it is.

      Reply
    18. sam on December 5, 2018 7:20 am

      Thank you ..it so valuable information

      Reply
    19. salam on November 26, 2018 6:00 am

      Thank you

      Reply
    20. manchoy on November 23, 2017 3:36 pm

      After typed this command, when I typed “node -v” show error “no such file or directory”. Give me a help please!
      ln -sf /usr/local/n/versions/node/6.0.0/bin/node /usr/bin/node

      Reply
    21. Hari on August 12, 2017 3:29 pm

      Thanks a lot

      Reply
    22. Nicolas on July 27, 2017 5:13 am

      Worked, Thanks!

      Reply
    23. Rupert on May 22, 2017 12:20 pm

      Nice work! Good little guide, just enough detail to upgrade Node.Js safely – thanks

      Reply
    24. PAblo on March 26, 2017 2:03 am

      Thanks!

      Reply
    25. Jinger on November 1, 2016 8:48 am

      Thank you very much for this! I was trying to install LESS but was having a hard time. It turns out it’s just the version compatibility with my node. I finally get it to work.:D

      Reply
    26. udayan debnath on August 15, 2016 9:03 pm

      Thanks man….. You are my hero …. There are many option to do that all over the net including nodejs.org. But i understand that once npm is installed as a package manager then it should be done by npm itself. I used fedora 24 with dnf to install the default package from the repo. Then upgrade npm and then node…. thanks again…. now i am learning npm cli command before anything.

      Reply
    27. Skip on August 11, 2016 2:10 am

      Or if you installed using homebrew, you can omit the ‘sudo’…

      Reply
    28. Kannan on July 21, 2016 4:40 am

      Thank you bro , worked to me.

      Reply
    29. Muhammad Shidiq on June 28, 2016 4:18 am

      Awesome!

      Reply
    30. Ljubo Opaki on June 10, 2016 8:52 am

      worked 🙂 thanks man

      Reply
    31. Ami Mishra on May 31, 2016 12:16 pm

      Very Nice @ Rahul

      Thanu!!

      Reply
    32. Vuyani on May 30, 2016 2:43 pm

      Thank you so much, so helpful!

      Reply
    33. Kate on May 17, 2016 7:38 pm

      Works on Fedora 21. Thanks a lot!

      Reply
    34. stephen on April 20, 2016 11:38 am

      Is this powershell, command prompt…(windows,Mac,Linux) sudo suggest linux ..so probabbly mac lynux. node -v is the only thing that worked for me. Should i just download the node windows install and run tha

      Reply
    35. Joey on March 6, 2016 9:26 pm

      Hi, I hope you can help me out. I tried to upgrade my Pi but I still have an older version of nodejs:

      [email protected]:~ $ node -v
      v5.6.0

      [email protected]:~ $ nodejs -v
      v0.10.29

      Reply
      • Rahul on March 7, 2016 7:37 am

        Hi Joey,

        Create a symbolic link for nodejs command also.

        Reply
    36. Chris on March 3, 2016 10:55 pm

      wtf this just broke the node command for me… when I punch in node -v or any node command now it gives me /usr/bin/node: No such file or directory. awesome.

      Reply
      • Duncan on March 7, 2016 7:32 pm

        I just had that same thing happen to me, how did you fix it?

        Reply
    37. Neville Franks on February 19, 2016 11:24 pm

      Note that the line:
      sudo ln -sf /usr/local/n/versions/node/5.0.0/bin/node /usr/bin/node
      will need the 5.0.0 version number updated to match the stable version that was installed.

      Reply
    38. MAX on February 14, 2016 1:21 pm

      hello

      about ‘Setup Binary Link’

      i can’t find “`/usr/bin/node“` in my osx

      and then i type “`node -v“`

      the latest version already installed.

      I survey other post , find other user no do this step.

      https://github.com/tj/n/issues/307

      Thank your share.

      Reply
    39. babababababa on January 18, 2016 7:31 pm

      Doesn’t work on windows:

      npm ERR! notsup Unsupported
      npm ERR! notsup Not compatible with your operating system or architecture: [email protected]
      .0
      npm ERR! notsup Valid OS: !win32
      npm ERR! notsup Valid Arch: any
      npm ERR! notsup Actual OS: win32
      npm ERR! notsup Actual Arch: x64

      Reply
      • agoga on January 27, 2016 4:05 pm

        have the same error on Win 8.1

        Reply
    40. Craig R Morton on January 18, 2016 1:28 pm

      Spot on, this works for me on CentOS 7 where many other instructions I found did not.

      Reply
    41. Gary Hall on December 14, 2015 5:02 pm

      Thanks for your help!

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Configure Postfix to Use Gmail SMTP on Ubuntu & Debian
    • PHP Arrays: A Beginner’s Guide
    • Deploying Flask Application on Ubuntu (Apache+WSGI)
    • OpenSSL: Working with SSL Certificates, Private Keys and CSRs
    • How to Create and Read List in Python
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.