| name | yarn |
| description | Yarn commands for package management (v1 and v4/berry) |
| argument-hint | [command or question] |
| allowed-tools | Bash, Read |
Help with Yarn based on $ARGUMENTS.
Yarn Classic (v1)
Package Management
yarn init
yarn init -y
yarn
yarn add lodash
yarn add -D typescript
yarn add lodash@4.17.21
yarn remove lodash
yarn upgrade
yarn upgrade lodash
yarn outdated
Scripts
yarn run build
yarn build
yarn test
yarn dev
Yarn Modern (v4/Berry)
Setup
corepack enable
yarn set version stable
Package Management
yarn
yarn add lodash
yarn add -D typescript
yarn up
yarn up lodash
yarn remove lodash
Workspaces
yarn workspace @myorg/web build
yarn workspaces foreach run build
yarn workspace @myorg/web add lodash
Plugins (v4)
yarn plugin import typescript
yarn plugin import workspace-tools
yarn plugin list
Common to Both
Info Commands
yarn why lodash
yarn list
yarn info lodash
Cache
yarn cache clean
yarn cache clear
Configuration
nodeLinker: node-modules
enableGlobalCache: true
nodeLinker: pnp
package.json Scripts
{
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"test": "vitest",
"lint": "eslint src/"
}
}
Yarn vs npm Commands
| Action | npm | yarn |
|---|
| Install all | npm install | yarn |
| Add package | npm install pkg | yarn add pkg |
| Add dev | npm install -D pkg | yarn add -D pkg |
| Remove | npm uninstall pkg | yarn remove pkg |
| Run script | npm run cmd | yarn cmd |
| Clean install | npm ci | yarn --frozen-lockfile |