Node Version Manager install - nvm command not found

后端 未结 26 1767
名媛妹妹
名媛妹妹 2020-11-30 16:18

I am trying to install NVM as per these instructions

I typed in this command in terminal:

$ curl https://raw.github.com/creationix/nvm/master/instal         


        
26条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-30 16:49

    The nvm install script by default adds initialization code to your $HOME/.profile, which is only loaded by a login shell (in a desktop environment you may never see a login shell).

    The nvm command in your login shell is not propagated to sub-shells (like console windows and IDE terminals after you log in). This snippet in your $HOME/.bashrc will only load nvm if it is an interactive shell and has not been loaded already

    # if nvm dir is not set and the standard nvm directory exists
    if [ -z "$NVM_DIR" -a -d "$HOME/.nvm" ] ; then
    # set nvm dir
      export NVM_DIR="$HOME/.nvm"
    fi
    
    # if nvm dir is set and this shell is interactive
    if [ -d "$NVM_DIR" -a -n "$PS1" ] ; then
      # if nvm command is not defined
      if ! type -t nvm >/dev/null ; then
        # set it
        source "$NVM_DIR/nvm.sh"
      fi
    fi
    

    Putting this in your $HOME/.bashrc file will fix the missing nvm problem in interactive bash shells, even from a gui, and even if nvm is installed in a non-standard location.

提交回复
热议问题