npm 和 yarn 命令对照表

以typescript为例子

  • 初始化项目
    npm init
    yarn init

  • 根据package.json安装
    npm install
    yarn

  • 安装具体的包
    npm install typescript
    yarn add typescript

  • 安装制定版本的包
    npm install [email protected]
    yarn add [email protected]

  • 安装到生产环境
    npm install typescript --save-dev 或者 npm install typescript -D
    yarn add typescript --dev 或者 yarn add typescript -D

  • 安装到全局
    npm install typescript --global 或者npm install typescript -g
    yarn global add typescript

  • 卸载
    npm uninstall typescript 或者 npm un typescript
    yarn remove typescript

  • 更新
    npm upade typescript --laste --save
    yarn upgrade typescript

  • 更新全局
    npm update typescript --global
    yarn global upgrade typescript

  • 清除缓存
    npm cache clean
    yarn cache clean

  • 重新下载所有包
    npm rebuild
    yarn add --force

  • 发布
    npm publish
    yarn publish

  • 登录
    npm login
    yarn login

  • 退出
    npm logout
    yarn logout

  • 运行命令
    npm run dev
    yarn run dev

  • 展示已经安装的包
    npm ls typescript -g
    yarn list typescript -g

你可能感兴趣的:(前端,npm,前端,typescript)