Homebrew installs nvm but nvm can't be found afterwards?

前端 未结 10 1306
既然无缘
既然无缘 2020-12-22 20:53

I\'m using homebrew and oh-my-zsh on a fresh OSX 10.10.1 install. I got nvm via homebrew and then attempted to run it but

相关标签:
10条回答
  • 2020-12-22 21:32

    While the accepted answer does technically work, it's worth noting that Homebrew installation is not officially supported by the nvm package. The recommended way to avoid issues like those raised above is to apply either of the below methods of installation.

    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
    
    # or wget:
    wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
    

    source: https://github.com/creationix/nvm

    0 讨论(0)
  • 2020-12-22 21:32

    I've spent a couple of hours going round and round on this issue, but I've come to the conclusion that DarkPurple141 is right: nvm just isn't compatible with Homebrew, as they state on their Github nvm-sh/nvm Node Version Manager. Homebrew will install nvm and everything looks fine, until one tries to get npm to install a module, Mocha in my case. That threw me right back to the dreaded error:

    ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

    NOTE: On step 3, make sure to replace version with correct release.

    The solution, on MacOS 10.14 Mojave, was:

    1. $ brew uninstall nvm
    2. $ brew cleanup (just for good measure)
    3. $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
    4. Check that nvm was installed correctly by running $ command -v nvm.

      4.a If the response is anything other than $ nvm, add the following two lines to the ~/.bash-profile file: export NVM_DIR=~/.nvm source ~/.nvm/nvm.sh 4.b Restart your computer (you can try closing Terminal and restarting it first) 4.c $ command -v nvm should now returnnvm`

    5. Now update Node.js with $ nvm install --lts

    6. Update npm: $ nvm install-latest-npm
    7. $ npm install --global mocha. Finally, success! Well, for me and I hope for you too.
    0 讨论(0)
  • 2020-12-22 21:40

    To install nvm, brew install nvm

    To run nvm after installation or just once, $(brew --prefix nvm)/nvm.sh

    To run nvm everytime zsh opens

    1. nano ~/.zshrc
    2. Add this line source $(brew --prefix nvm)/nvm.sh
    0 讨论(0)
  • 2020-12-22 21:41

    I'd like to add that nvm's location on github changed and the version bumped. The curl command now should be:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
    
    0 讨论(0)
提交回复
热议问题