Search code examples
node.jssublimetextzshoh-my-zshnvm

NVM cannot load default node with default alias set


My problem is almost the same as this one but i already set the default alias.

Once i open a new console nvm does not load the default node, this problem is also present with some SublimeText3 plugins (eslint, jscs for example).

The only way to make it work is to add nvm use default after loading nvm but i thik i am doing something wrong.

How can i make it work without the hack?


My configuration

  • brew 0.9.5
  • nvm 0.26.0 (installed using brew)
  • zsh (with oh-my-zsh)

I have nvm sourced in .zshenv with th following config:

export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
# nvm use default # <-- remove comment to make node available

nvm is configured as follows (result of the command nvm ls):

iojs-v3.0.0
v0.12.7
default -> iojs (-> iojs-v3.0.0)
node -> stable (-> v0.12.7) (default)
stable -> 0.12 (-> v0.12.7) (default)
iojs -> iojs-v3.0 (-> iojs-v3.0.0) (default)


Solution

  • oh-my-zsh includes a nvm plugin, I would recommend you to use it, but first

    1. remove from your .zshenv all changes
    2. remove the nvm install with brew uninstall
    3. install nvm using curl (official installation): curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.26.0/install.sh | bash this wont configure your profile to use it yet.
    4. edit the file at your users home called .zshrc finding the plugins section and there include nvm save it and source your profile or close and open again your terminal.
    5. use nvm to install a node version and set the default alias