当前位置:   article > 正文

工作日记:Ubuntu安装npm、nodejs和yarn_ubuntu22.04 用国内源安装node,yarn

ubuntu22.04 用国内源安装node,yarn

一、更新apt源

# 使用清华大学 Ubuntu 软件镜像
sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
apt update
  • 1
  • 2
  • 3

二、安装npm

# 安装npm
apt install npm

# 验证安装
npm -version

# 更换淘宝源
npm config set registry https://registry.npm.taobao.org

# 验证源是否更换成功
npm config get registry 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

三、安装nodejs

# 在全局安装n模块,用n模块管理nodejs
npm install -g n

# 下载指定版本的nodejs
n v14.19.0

# 刷新bash, zsh, ash, dash, ksh
hash -r
# 如果用的是tcsh请使用下面的命令
# rehash

# 验证安装
node -v
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

四、安装yarn

(1)安装步骤

# 安装yarn
npm install -g yarn

# 验证安装
yarn --version

# 更换淘宝源
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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

(2)常用yarn命令
传送门,Biu~

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/1021103
推荐阅读
相关标签
  

闽ICP备14008679号