webIDE 终端里 快速初始化golang和nodejs
文档说明:只记录关键地方;
试验环境: webIDE vscode网页版 code-server
目标: webIDE 终端 里能快速使用 golang, nodejs, python3, pip3
test ! -f /etc/apt/source.list.save && cp /etc/apt/sources.list /etc/apt/sources.list.save
sed -i "s@deb.debian.org@mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list && \
sed -i "s@security.debian.org@mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list
apt update -y && apt install -y curl vim sudo tini libssl-dev ca-certificates && \
apt install -y git curl wget make cmake gcc g++ python3 python3-pip ninja-build && \
apt install -y net-tools dnsutils iproute2 procps iputils-ping
快速安装golang 环境
#!/bin/bash
set -exu
__CURRENT__=`pwd`
__DIR__=$(cd "$(dirname "$0")";pwd)
cd ${__DIR__}
kernel_name=$(uname -s)
echo "$kernel_name"
# https://golang.google.cn/dl/
golang_linux="https://golang.google.cn/dl/go1.19.2.linux-amd64.tar.gz"
golang_mac="https://golang.google.cn/dl/go1.19.2.darwin-amd64.pkg"
golang_win="https://golang.google.cn/dl/go1.19.2.windows-amd64.msi"
if test "$kernel_name" = "Linux"; then
{
if [ ! -f go1.19.2.linux-amd64.tar.gz ]
then
{
curl -L -O $golang_linux
tar -zxvf go1.19.2.linux-amd64.tar.gz
}
fi
export PATH=$PATH:${__DIR__}/go/bin/
# echo "PATH=$PATH:"${__DIR__}/go/bin/" >> /etc/profile
}
elif test "$kernel_name" = "Darwin"; then
{
if [ ! -f go1.19.2.linux-amd64 ]
then
{
curl -L -O $golang_mac
}
fi
export PATH=$PATH:${__DIR__}/go/bin/
# echo "PATH=$PATH:"${__DIR__}/go/bin/" >> ~/.zshrc
}
else
{
# MSYS2
if [ ! -f go1.19.2.windows-amd64.msi ]
then
curl -L -O $golang_win
fi
#set PATH=%PATH%;${__DIR__}\\golang_win\\bin
}
fi
# export GOPROXY=https://mirrors.aliyun.com/goproxy/
$user=$(whoami)
GOPATH=/home/$user/gopath
mkdir -p /home/$user/gopath
快速安装nodejs
#!/bin/bash
set -exu
__CURRENT__=`pwd`
__DIR__=$(cd "$(dirname "$0")";pwd)
cd ${__DIR__}
kernel_name=$(uname -s)
echo "$kernel_name"
# https://nodejs.org/zh-cn/
# https://registry.npmmirror.com/binary.html?path=node/
# https://nodejs.org/dist/v18.12.0/node-v18.12.0-linux-x64.tar.xz
version='18.12.0'
nodejs_linux="https://registry.npmmirror.com/-/binary/node/latest-v18.x/node-v${version}-linux-x64.tar.gz"
nodejs_mac="https://registry.npmmirror.com/-/binary/node/latest-v18.x/node-v${version}-darwin-x64.tar.gz"
nodejs_win="https://registry.npmmirror.com/-/binary/node/latest-v18.x/node-v${version}-win-x64.zip"
if test "$kernel_name" = "Linux"; then
{
if [ ! -f node-v${version}-linux-x64.tar.gz ]
then
{
curl -L -O $nodejs_linux
tar -zxvf node-v${version}-linux-x64.tar.gz
}
fi
export PATH=$PATH:${__DIR__}/node-v${version}-linux-x64/bin/
# echo "PATH=$PATH:"${__DIR__}/node-v${version}-linux-x64/bin/" >> /etc/profile
}
elif test "$kernel_name" = "Darwin"; then
{
if [ ! -f node-v${version}-darwin-x64.tar.gz ]
then
{
curl -L -O $nodejs_mac
tar -zxvf node-v${version}-darwin-x64.tar.gz
}
fi
export PATH=$PATH:${__DIR__}/node-v${version}-darwin-x64/bin/
# echo "PATH=$PATH:"${__DIR__}/node-v${version}-darwin-x64/bin/" >> ~/.zshrc
}
else
{
# MSYS2
if [ ! -f node-v${version}-win-x64.zip ]
then
curl -L -O $nodejs_win
unzip node-v${version}-win-x64.zip
fi
set PATH=%PATH%;${__DIR__}\\node-v${version}-win-x64\\bin
}
fi
# npm i -g yarn --registry https://registry.npmmirror.com --unsafe-perm
# npm config set registry https://registry.npmmirror.com
# npx yarn config set registry https://registry.npmmirror.com
# npx yarn install
# yarn upgrade --latest
# yarn upgrade-interactive --latest
.npmrc 文件
registry=https://registry.npmmirror.com
electron_mirror=https://npmmirror.com/mirrors/electron/
sass_binary_site=https://npmmirror.com/mirrors/node-sass/
SASS_BINARY_SITE=http://npmmirror.com/mirrors/node-sass
puppeteer_download_host=https://npmmirror.com/mirrors/
chromedriver_cdnurl=http://npmmirror.com/mirrors/chromedriver
PYTHON_MIRROR=http://npmmirror.com/mirrors/python
profiler_binary_host_mirror=http://npmmirror.com/mirrors/node-inspector/
SQLITE3_BINARY_SITE=http://npmmirror.com/mirrors/sqlite3
NVM_NODEJS_ORG_MIRROR=http://npmmirror.com/mirrors/node
NVMW_NPM_MIRROR=http://npmmirror.com/mirrors/npm
phantomjs_cdnurl=http://npmmirror.com/mirrors/phantomjs
python3 pip
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple