Npm & Yarn 命令 | 安装 | 卸载 | 镜像

目录

  • Npm
    • 查看npm当前版本
    • 初始资源库
    • 升级最新版本
    • 升级到指定版本
    • 安装插件指定版本
    • 默认配置 - - - 查看npm内部的配置参数,和没有特别指定的默认值
    • 查询资源库
    • 设置淘宝镜像 **ps:**[镜像](https://zhuanlan.zhihu.com/p/432578145)
    • 配置后可通过下面命令来验证是否成功
    • 临时使用镜像
  • Yarn
    • 安装yarn
    • 初始化一个项目
    • 安装依赖包
    • 更新依赖包
    • 删除依赖包
    • 安装所有依赖包
    • 发布包
    • 查看包的缓存列表
    • 全局安装包 == npm -g

Npm

查看npm当前版本

npm -v

初始资源库

npm config set registry https://registry.npmjs.org/

升级最新版本

npm install -g npm

升级到指定版本

npm -g install [email protected]

安装插件指定版本

npm install --save [email protected]

默认配置 - - - 查看npm内部的配置参数,和没有特别指定的默认值

npm config ls -l

查询资源库

npm config get registry

设置淘宝镜像 ps:镜像

new: npm config set registry https://registry.npmmirror.com
old: npm config set registry https://registry.npm.taobao.org

配置后可通过下面命令来验证是否成功

npm config ls

临时使用镜像

new:npm --registry https://registry.npmmirror.com install node-sass
old:npm --registry https://registry.npm.taobao.org install node-sass

Yarn

安装yarn

npm install -g yarn

初始化一个项目

yarn init

安装依赖包

yarn add packagename
yarn add packagename --dev

更新依赖包

yarn upgrade packagename

删除依赖包

yarn remove packagename

安装所有依赖包

yarn
yarn install

发布包

yarn publish

查看包的缓存列表

yarn cache list

全局安装包 == npm -g

yarn global

你可能感兴趣的:(Hybrids,node.js,yarn)