brew nvm 卸载 和 brew nvm&&node 安装

为什么80%的码农都做不了架构师?>>>   hot3.png

删除

1.卸载指令:

npm ls -g --depth=0 # 查看已经安装在全局的模块,以便删除这些全局模块后再按照不同的 node 版本重新进行全局安装
sudo rm -rf /usr/local/lib/node_modules # 删除全局 node_modules 目录
sudo rm /usr/local/bin/node # 删除 node
cd  /usr/local/bin && ls -l | grep "../lib/node_modules/" | awk '{print $9}'| xargs rm # 删除全局 node 模块注册的软链

删除当前用户目录下的 .nvm .npm .node

2.vi .bash_profile

export PATH=${PATH}:/usr/local/mysql/binexport PATH="/usr/local/bin:$PATH"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
export PATH=~/.composer/vendor/bin:$PATH
export ANDROID_HOME=/Users/lph/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/sbin:$PATH"

删除 

export NVM_DIR="$HOME/.nvm"

[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

 

安装nvm&&node

1.brew 安装nvm

$ brew update   #更新如果报错请执行: rm -rf /usr/local/share/doc/homebrew 
$ brew install nvm
==> Downloading https://github.com/creationix/nvm/archive/v0.34.0.tar.gz
==> Downloading from https://codeload.github.com/creationix/nvm/tar.gz/v0.34.0
######################################################################## 100.0%
==> Caveats
Please note that upstream has asked us to make explicit managing
nvm via Homebrew is unsupported by them and you should check any
problems against the standard nvm install method prior to reporting.

You should create NVM's working directory if it doesn't exist:

  mkdir ~/.nvm

Add the following to ~/.bash_profile or your desired shell
configuration file:

  export NVM_DIR="$HOME/.nvm"
  [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"  # This loads nvm
  [ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion"  # This loads nvm bash_completion

You can set $NVM_DIR to any location, but leaving it unchanged from
/usr/local/opt/nvm will destroy any nvm-installed Node installations
upon upgrade/reinstall.
....

接下來要把 nvm 加入 shell 中,就可以直接在 terminal 直接使用

$ echo "source $(brew --prefix nvm)/nvm.sh" >> .bash_profile
$ . ~/.bash_profile
$ nvm --version #查看nvm版本

2.nvm install node

通过nvm安装node

$ nvm ls-remote #查看node 安装版本
$ nvm install  v10.0.0 #这里按照版本10
Downloading and installing node v10.0.0...
Downloading https://nodejs.org/dist/v10.0.0/node-v10.0.0-darwin-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v10.0.0 (npm v5.6.0)
Creating default alias: default -> v10.0.0
$ node -v 
v10.0.0

 

转载于:https://my.oschina.net/oslph/blog/1926969

你可能感兴趣的:(shell,移动开发,awk)