Skip to content

Instantly share code, notes, and snippets.

@Aermberry
Last active December 17, 2023 14:50
Show Gist options
  • Save Aermberry/b3cefabde655312ec6d8cd52e9120eeb to your computer and use it in GitHub Desktop.
Save Aermberry/b3cefabde655312ec6d8cd52e9120eeb to your computer and use it in GitHub Desktop.
linux_install_configuration
#! /bin/Bash
# 检测是否已安装 nvm
if [ -d "$HOME/.nvm" ]; then
echo "nvm 已经安装"
else
# 下载并安装 nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# 将相关配置添加到 ~/.profile
echo '# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> ~/.profile
# 刷新当前 Shell 环境
source ~/.profile
# 显示 nvm 的版本
echo "已经安装 nvm,当前的版本是 $(nvm --version)"
# 安装最新的稳定版 Node.js 和 npm
nvm install --lts
# 启用 pnpm 和 yarn
corepack enable
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment