Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to build a script in in which nvm and eventually node will get installed.
I have installed nvm with cURL. I see the modifications in the .profile or .bashrc file (both work) and when typing the nvm at the bash prompt, it shows the options available etc.
So nvm works. Manually I can install node, but as soon as I put the nvm command in a shell script:

nano test.sh

#!/bin/bash
nvm

and run it with:

chmod 755 test.sh
./test.sh

I get:

./test.sh: line 2: nvm: command not found

If it can't find nvm, I don't even have to think of

nvm ls-remote 

or

nvm install ...

I got Ubuntu 14.04 installed and Bash is my shell.

share|improve this question
    
I'd print the path in the script before calling nvm and check if it is correct. –  AProgrammer Feb 12 at 17:29

1 Answer 1

up vote 1 down vote accepted

nvm command is a shell function declared in ~/.nvm/nvm.sh.

You may source either of following scripts at the start of yours to make nvm() available:

. ~/.nvm/nvm.sh
. ~/.profile
. ~/.bashrc
share|improve this answer
    
HI, thanks. This makes sense then as nvm is "installed" in ~/.nvm. And is probably just a shell script. What I am missing though is that I can type nvm and get it to work, but when trying the shell scripts in ~/.nvm it doesn't work. –  okidoki Feb 12 at 17:42
    
what do you mean by trying the shell scripts in ~/.nvm? I explained how to run nvm from the shell script above. Is there anything unclear? –  webKnjaZ Feb 12 at 17:45
    
To elaborate my last comment. when I "sudo find / -iname nvm*" I find only things in my ~/.nvm folder. Executing the ~/.nvm/nvm-exec or ~/.nvm/nvm.sh (the only files in ~/.nvm, which turn out to be shell scripts) does not give me nvm, like just typing "nvm" on the command line. So where is the link between nvm and the program. –  okidoki Feb 12 at 17:47
    
Oh.. I guess nvm is an alias in your shell environment. Please post the output of which nvm and this will clear things out. –  webKnjaZ Feb 12 at 17:50
    
Hi webKnjaZ, this does not provide output... –  okidoki Feb 12 at 17:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.