How do I source a shell script for Node Version Manager?

7,026

try this:

  1. Open the file vim /etc/profile
  2. insert the following lines, customize it for your own

$ . ~/nvm/nvm.sh

$ nvm use 0.8.13

Now, the nvm shell script runs through each time you log in.

hope it helps,

Share:
7,026

Related videos on Youtube

Matt Cashatt
Author by

Matt Cashatt

I love to code and really enjoy being on Stackoverflow. It has taught me a ton.

Updated on September 18, 2022

Comments

  • Matt Cashatt
    Matt Cashatt almost 2 years

    Hi and thanks for looking!

    I am new to Linux/Ubuntu, but I have set up an Ubuntu box on which to run Node.js. I have had moderate success, but now I need to be able to easily upgrade my version of Node.
    Many folks recommend using Node Version Manager. I followed the directions, but when I try to do something like this:

    nvm ls
    

    I get a messaging stating that

    No command NVM found
    

    I have gone back to check the steps I followed to install NVM, but there is one part that is tricky for may and I think to be the culprit: sourcing the file for bash.

    From the instructions:

    To activate nvm, you need to source it from your bash shell

    . ~/nvm/nvm.sh

    I always add this line to my ~/.bashrc or ~/.profile file to have it automatically sources upon login. Often I also put in a line to use a specific version of node. So which file should I add this to? I am guessing profile since it's Ubuntu?

    Also, where in the file do I add this line? After I have added this line, do I need to reboot or anything?

    Any help would be deeply appreciated--especially if you can show me an example profile file with . ~/nvm/nvm.sh integrated so that I can see usage.

    Thanks,

    Matt

    • qbi
      qbi over 11 years
      If you put the line in your .bashrc you did everything right. If it didn't work I assume, that your installation of nvm is not in the directory ~/nvm. Can you tell where you installed nvm?