1、初始化一個新的項目
yarn init
2、添加一個依賴包
yarn add [package] yarn add [package]@[version] yarn add [package]@[tag]
3、安裝所有的依賴包
yarn 或者
yarn install
4、npm 與 yarn命令比較
NPM | YARN | 說明 |
---|---|---|
npm init | yarn init | 初始化某個項目 |
npm install/link | yarn install/link | 默認的安裝依賴操作 |
npm install taco —save | yarn add taco | 安裝某個依賴,並且默認保存到package. |
npm uninstall taco —save | yarn remove taco | 移除某個依賴項目 |
npm install taco —save-dev | yarn add taco —dev | 安裝某個開發時依賴項目 |
npm update taco —save | yarn upgrade taco | 更新某個依賴項目 |
npm install taco --global | yarn global add taco | 安裝某個全局依賴項目 |
npm publish/login/logout | yarn publish/login/logout | 發布/登錄/登出,一系列NPM Registry操作 |
npm run/test | yarn run/test | 運行某個命令 |