【笔记】Nvm学习笔记 发表于 2022-09-17 更新于 2024-09-07 阅读次数: 前言 nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL.(Github) 安装Nvm Linux 1wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash 修改环境变量 ~/.bashrc12export 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 1source ~/.bashrc MacOS 安装nvm 1brew install nvm 创建工作目录 1mkdir ~/.nvm 添加环境变量 ~/.zshrc1234# Setting PATH for Node Version Managerexport NVM_DIR="$HOME/.nvm"[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" 更新环境变量 1source ~/.zshrc 查看nvm版本 1nvm --version 查看当前使用的node版本 1nvm list 查看可以安装的node版本 1nvm ls-remote 安装指定版本node <version>:版本号 1nvm install <version> 安装稳定版 1nvm install stable 卸载其他版本 <version>:版本号 1nvm uninstall <version> 切换版本 1nvm use <version> 完成 完成 参考文献 简书——my木子 简书——Angeladaddy