大家好,又见面了,我是你们的朋友全栈君。
Updated@2022-03-04
The acticle is out of date, try this instead:
yarn安装和配置国内源_jaket5219999的博客-CSDN博客_yarn配置国内
———————————————————————————————-
Updated at 2020-03-11
代码语言:javascript复制sudo apt update
sudo apt install nodejs
sudo apt install npm
sudo npm i -g npm --registry https://registry.npm.taobao.org
sudo npm i -g yarn --registry https://registry.npm.taobao.org
yarn config set registry https://registry.npm.taobao.org -g
yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g
export NVM_NODEJS_ORG_MIRROR=http://npm.taobao.org/mirrors/node
npm config set registry https://registry.npm.taobao.org
—————————— Before updated
操作系统为ubuntu18
第一步:换源
代码语言:javascript复制sudo python -c "s='mirrors.163.com';import re;f=open('/etc/apt/sources.list','r ');a=f.read();f.seek(0);f.truncate();f.write(re.sub(r'(deb|security).debian.org', s, a));f.close()"
参考:ubuntu 换源_jaket5219999的博客-CSDN博客
第二步:安装yarn
代码语言:javascript复制sudo apt-get update
sudo apt-get upgrade
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install yarn
# 如果用的是nvm,要这样安装:
# sudo apt install --no-install-recommends yarn
yarn --version
参考:How To Install Yarn on Ubuntu 18.04 LTS – idroot
第三步:给yarn换淘宝源
代码语言:javascript复制yarn config set registry https://registry.npm.taobao.org
参考:yarn设置淘宝镜像问题 亲测成功_菜菜程序员-CSDN博客_yarn配置镜像仓库
第四步:安装vue
代码语言:javascript复制yarn global add @vue/cli
参考:Installation | Vue CLI
——————————————————————————
如果安装完找不到vue,可用find命令找到vue所在目录,把该目录加给PATH
代码语言:javascript复制sudo find / -name "vue"
# /home/vagrant/.yarn/bin/vue
代码语言:javascript复制echo '# set PATH for yarn
if [ -d "$HOME/.yarn/bin" ] ; then
PATH="$HOME/.yarn/bin:$PATH"
fi' >> ~/.profile
. ~/.profile
vue --version
# 3.4.1
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/141495.html原文链接:https://javaforall.cn