mac环境下,pkg包安装
nodejs 官网下载
验证
> which node
/User/<your's-user-name>/.nvm/versions/node/<latest-node-lts-version>/bin/node
> node -v
v10.16.3
pkg卸载
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
brew 安装node
brew search
> brew search node
==> Formulae
leafnode node-build node@8 nodenv
libbitcoin-node node-sass node_exporter
llnode node@10 nodebrew
node node@12 nodeenv
==> Casks
nodebox nodeclipse soundnode
安装
brew install node@12
// 建立软连接
> ln -s ~/.nvm/versions/node/ /usr/local/Cellar/
brew 卸载node
> brew uninstall node --ignore-dependencies
Error: No such keg: /usr/local/Cellar/node
解决方法:
brew uninstall node --force
mac nvm 安装node
brew install nvm
brew install nvm
> nvm ls-remote
...
v10.16.2 (LTS: Dubnium)
-> v10.16.3 (LTS: Dubnium)
v10.17.0 (LTS: Dubnium)
v10.18.0 (Latest LTS: Dubnium)
...
v11.9.0
v11.10.0
....
v12.0.0
v12.1.0
...
v12.13.0 (LTS: Erbium)
v12.13.1 (LTS: Erbium)
v12.14.0 (Latest LTS: Erbium)
...
v13.4.0
v13.5.0
> nvm ls-remote --lts=Erbium
v12.13.0 (LTS: Erbium)
v12.13.1 (LTS: Erbium)
v12.14.0 (Latest LTS: Erbium)
nvm install v12.13.0
> nvm current
v10.16.3
常用nvm命令
命令 | 描述 |
---|---|
nvm --help | 展示帮助信息 |
nvm --version | 查看nvm版本 |
nvm install [-s] [version] | 安装特定版本node |
nvm install --reinstall-packages-from=[version] | 重新安装特定版本 |
nvm install --lts | 选择最新的LTS版本安装 |
nvm install --lts=[LTS name] | 选择特定的LTS版本安装 |
nvm install --skip-default-packages | 跳过默认包安装 |
nvm install --latest-npm | 安装完毕,顺带更新npm |
nvm install --no-progress | 静默安装,不显示进度条 |
nvm uninstall [version] | ** 卸载特定版本** |
nvm uninstall --lts | 卸载最新的LTS版本 |
nvm uninstall --lts=[LTS name] | ** 卸载特定的LTS版本** |
nvm use [--silent] [version] | 切换node版本 |
nvm use --lts | 使用最新的LTS版本 |
nvm use --lts=[LTS name] | 使用特定的LTS版本 |
nvm exec [--silent] [version] [command] | 使用特定node版本作为执行上下文 |
nvm exec --lts | 使用最新node LTS版本作为执行上下文 |
nvm exec --lts=[LTS name] | 使用特定LTS node版本作为执行上下文 |
nvm run [--silent] [version] [args] | 使用参数args代入版本node上下文执行命令 |
nvm run --lts | 使用最新LTS版本 |
nvm run --lts=[LTS name] | 使用特定LTS版本 |
nvm current | ** 展示当前使用的node版本** |
nvm ls [version] | 展示已安装的node版本 |
nvm ls --no-colors | 不使用颜色区分输出内容 |
nvm ls --no-alias | 仅仅输出版本号,不输出额外信息 |
nvm ls-remote [version] | 列出可供安装的node版本 |
nvm ls-remote --lts | 列出最新的LTS版本 |
nvm ls-remote --lts=[LTS name>] | 列出特定名称LTS版本 |
nvm ls-remote --no-colors | 不颜色区分输出 |
nvm version [version] | 查看nvm版本 |
nvm version-remote [version] | 查看源特定版本信息 |
nvm version-remote --lts | 查看源最新LTS版本信息 |
nvm version-remote --lts=[LTS name>] | 查看源特定LTS版本信息 |
nvm deactivate | Undo effects of nvm on current shell |
nvm alias [pattern] | 正则查找别名 |
nvm alias --no-colors | Suppress colored output |
nvm alias [name] [version] | 特定版本设置别名name |
nvm unalias [name] | 移除之前的设置的版本别名 |
nvm install-latest-npm | 更新node下的npm包 |
nvm reinstall-packages [version] | 重新更新node下npm包 |
nvm unload | shell下卸载nvm |
nvm which [current [version]] | 展示node path路径 |
nvm cache dir | 展示nvm的缓存路径 |
nvm cache clear | 清空nvm缓存 |
软连接作用
> ln -s ~/.nvm/versions/node/<latest-node-lts-version>/ /usr/local/Cellar/node
nvm 卸载 node
> nvm uninstall v10.16.2
Uninstalled node v10.16.2
windows下nvm
nvm命令
nvm 安装node
nvm install 10.16.3
查看可用列表
linux 下安装nvm
安装git
yum install git -y
下载nvm
git clone git://github.com/creationix/nvm.git ~/nvm
编译安装nvm
#设置nvm 自动运行;
echo "source ~/nvm/nvm.sh" >> ~/.bashrc
source ~/.bashrc