Unable to change version of node with brew switch

2019-03-01 17:32发布

I'm trying to use node 8.9.1 but when trying to update using brew it says 8.9.1 is already installed

James-MacBook:~ james$ brew upgrade node
Error: node 8.9.1 already installed

But when checking the version it shows

James-MacBook:~ james$ node --version
    v0.10.48

So then I tried to switch to 8.9.1

James-MacBook:~ james$ brew switch node 8.9.1
Cleaning /usr/local/Cellar/node/8.9.1
7 links created for /usr/local/Cellar/node/8.9.1

But it is still showing as 0.10.48

James-MacBook:~ james$ node --version
v0.10.48

1条回答
Anthone
2楼-- · 2019-03-01 18:21

It sounds like you have some version of node that is installed without using Homebrew.

  1. First of all, check if you installed your node with nvm by check if you have a .nvm directory in home directory ls -la
    1. if you do, remove that directory
    2. brew update && brew install node@8 (whichever node you want)
    3. brew unlink node@0
    4. brew link --force node@8
    5. Do brew update && brew upgrade node@8

Happy coding

查看更多
登录 后发表回答