实际开发中,不同语言有不同的版本,不同项目对于版本又各有要求,因此有一个版本管理的工具,就能够比较容易地进行环境的快速切换,适配不同的项目要求
Node.Js#
使用工具:nvm ↗
安装流程
// 下载安装脚本
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash
// 加入 shell 启动文件中
// zsh: 加入 ~/.zshrc
// bash: 加入 ~/.bashrc
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
bash常用命令
// 安装/卸载指定版本
nvm install/uninstall 14.7.0 # or 16.3.0, 12.22.1, etc
// 查看版本列表
nvm list
// 使用指定版本
nvm use xxx
bashGolang#
使用工具:gvm ↗
安装流程
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
bash常用命令
gvm install go1.23.8
gvm list
gvm use go1.23.8
plaintextPython#
使用工具比较多,个人使用 miniconda
-
在清华镜像源 ↗中找到自己对应的版本
-
修改可执行权限
chmod a+x xxx.sh
-
运行安装
./xxx.sh
常用命令
// 创建环境
conda create -n env_name python=3.8
// 查看列表
conda env list
// 激活环境
conda activate env_name
//退出环境
conda deactivate
// 删除虚拟环境
conda remove --name env_name --all
// 删除指定包
conda remove --name env_name package_name
// 导出环境
#获得环境中的所有配置
conda env export --name myenv > myenv.yml
#重新还原环境
conda env create -f myenv.yml
bash参考链接