取代 npm 的新利器 Yarn

Guan-Yu Pan
Oct 12, 2016 · 3 min read

Yarn 提供一個更快更穩定的套件管理方案

如何使用

// 以前裝過 npm 再安裝 yarn
npm install -g yarn
// 直接安裝 (mac為例,其餘官網有介紹)
curl -o- -L https://yarnpkg.com/install.sh | bash
// 一般安裝 (等同 npm install)
yarn
// 安裝特定套件 (等同 npm install --save)
yarn add react
yarn add react@15.3.2
// 更新特定套件 (等同 npm upgrade)
yarn upgrade react
// 移除特定套件 (等同 npm uninstall)
yarn remove react
// 新增 package.json
yarn init
// 新增全域套件
yarn global add
// 跑 script
yarn run
// 其他常用選項
--offline (離線模式,只拉 cache)
--flat (將套件扁平化,一個資料夾只會有一個套件)
--dev (加入到 devDependencies)
--peer (加入到 peerDependencies)
--optional (加入到 optionalDependencies)

Guan-Yu Pan

Written by

#Haskell #React #Typescript #FP https://github.com/jackypan1989

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade