#1889·nvm

nvm install script fails to detect commented out nvm source string and bash_completion in ~/.bashrc

Author: tedmistonCreated Aug 14, 2018Updated Jun 20, 2026
Labelspull request wantedinstalling nvm
  • Operating system and version:

macOS 10.13.6 (17G65)

  • nvm debug output:
n/a
  • nvm ls output:
n/a
  • How did you install nvm? (e.g. install script in readme, Homebrew):

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

  • What steps did you perform?
  1. rm -rf $NVM_DIR

  2. mkdir $NVM_DIR

  3. commented out the following 2 lines in .bashrc while debugging nvm

    export NVM_DIR="$HOME/.nvm"
    # [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    # [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
    
  4. (launch a new shell)

  5. curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

  • What happened?

nvm does not add the proper commands to .bashrc because it doesn't realize they are commented out. Consequently, nvm also does not run since the script that loads it is never executed.

t-mbp:~ taylor$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12819  100 12819    0     0  87888      0 --:--:-- --:--:-- --:--:-- 88406
=> Downloading nvm from git to '/Users/taylor/.nvm'
=> Cloning into '/Users/taylor/.nvm'...
remote: Counting objects: 267, done.
remote: Compressing objects: 100% (242/242), done.
remote: Total 267 (delta 31), reused 86 (delta 15), pack-reused 0
Receiving objects: 100% (267/267), 119.47 KiB | 1.81 MiB/s, done.
Resolving deltas: 100% (31/31), done.
=> Compressing and cleaning up git repository

=> nvm source string already in /Users/taylor/.bashrc
=> bash_completion source string already in /Users/taylor/.bashrc
env: node: No such file or directory
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
t-mbp:~ taylor$ nvm
-bash: nvm: command not found

(Uncommenting these commands manually makes everything work as expected.)

  • What did you expect to happen?

I expected nvm to detect that the commands are not actually in .bashrc (since they're commented out) and to add them.

Additionally, it would be nice to see a warning if the commands are there but commented out (i.e., further up in the .bashrc file from previous installs or troubleshooting).

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?

Yes, I'm a developer so plenty of developer stuff but nothing else related to node / nvm besides the 3 lines added by nvm itself.