Node + npm + Yarn
使用指南配置
安装 Node
Linux 定义环境变量
vi /etc/profile
# Node
export PATH=$PATH:/home/node/node-v16.14.2-linux-x64/bin
配置参数
npm config set registry https://registry.npmmirror.com
NPM 命令
安装依赖
npm -v // 查看npm版本
npm install -g egg // 安装/更新 组件到全局
npm link --local egg // 项目引用全局组件
npm install --save-dev
npm i
npm install --registry=https://registry.npmmirror.com
npm config set registry https://registry.npmmirror.com
npm config get registry
npm config list // 显示配置
npm list -g --depth=0 // 显示全局组件, 深度=0
npm version // 查看模块版本列表
npm info zlib version // 查看zlib包版本
npm info zlib versions // 查看zlib包所有版本
npm info egg // 显示组件的信息
npm view egg // 显示组件的信息
安装 pnpm
npm config set registry https://registry.npmmirror.com
npm install -g pnpm
pnpm install # pnpm 安装依赖
安装 Yarn,提升依赖的安装速度
npm install --global yarn
yarn install # yarn 安装依赖
常见问题
- https://registry.npm.taobao.org/ failed, reason: certificate has expired, 证书过期
- 解决方法:变更镜像源 npm config set registry https://registry.npmmirror.com