Important: This documentation covers Yarn 2.
For 1.x docs, see
1 - Introduction2 - Installation3 - UsageEditor SDKsMigrationQuestions & AnswersRecipes


Edit this page on GitHub

TypeScript + PnP quick start:

  • Initialize the repo using Yarn 2:
yarn init -2
yarn add --dev typescript
yarn dlx @yarnpkg/pnpify --sdk vscode
yarn plugin import typescript

Running a Yarn CLI command in the specified directory:

  • Starting a new library inside a monorepo directly, without manually creating directories for it.
yarn packages/my-new-lib init
  • Running an arbitrary command inside a specific workspace:
yarn packages/app tsc --noEmit

Hybrid PnP + node_modules mono-repo:

You may sometimes need to use node_modules on just part of your workspace (for example, if you use Angular or React-Native).

  • Create a separate directory for the node_modules project.
mkdir nm-packages/myproj
  • Create an empty lockfile in the new project. Yarn uses lockfiles to locate the root of projects.
touch nm-packages/myproj/yarn.lock
  • Add a .yarnrc.yml file inside the new directory that enables node_modules just for it (nm-packages/myproj/.yarnrc.yml):
nodeLinker: node-modules
  • Add a PnP ignore pattern for this path in your main .yarnrc.yml at the root of your monorepo:
  - ./nm-packages/**
  • You can now run cd nm-package/myproj && yarn install and the project will be isolated from your pnp root.