Eliminating the Install Step: A Practical Look at Yarn Zero-Installs
Stop waiting for 'yarn install'. Learn how Yarn Plug'n'Play and Zero-Installs eliminate node_modules to accelerate CI/CD and ensure deterministic environments.
11 Sept 2025, 01:11 UTC

The Cost of the 'Install' Phase
In most JavaScript projects, the yarn install or npm install step is a mandatory bottleneck. Whether it is a developer onboarding to a new project or a CI/CD pipeline triggering a build, the process involves downloading hundreds of packages and extracting thousands of small files into a node_modules directory. This creates high disk I/O overhead and introduces the risk of network failures during critical deployments.
Yarn Zero-Installs solves this by treating dependencies as part of the source code rather than ephemeral artifacts. By combining Plug'n'Play (PnP) with a committed cache, you can move from a repository clone to a running application without ever executing an installation command.
How Plug'n'Play (PnP) Changes Resolution
Traditional Node.js resolution relies on a recursive search for node_modules folders. If a package isn't in the current directory, Node looks at the parent, and so on. This is slow and allows "phantom dependencies"—where a project can successfully import a package it doesn't actually list in package.json because it happens to be a dependency of another installed library.
Yarn PnP replaces this directory search with a single mapping file: .pnp.cjs. This file tells Node.js exactly where every package is located within a global cache. Instead of moving files into a local project folder, Yarn keeps packages as compressed zip archives. When your code requests a module, the PnP loader intercepts the request and points Node directly to the correct zip file.
Implementing Zero-Installs
To achieve Zero-Installs, you must commit the Yarn cache to your version control system. Because PnP uses zip files, the repository size remains manageable compared to the bloated node_modules folder, which is traditionally ignored via .gitignore.
Configuration Example
To set up a project for Zero-Installs using Yarn Berry (v2+), run these commands in your project root with administrative permissions for the local directory:
# Switch to the modern Yarn version
yarn set version berry
# Ensure the PnP linker is enabled in .yarnrc.yml
# (This is the default for Berry, but verify the file contains: nodeLinker: pnp)
# Install dependencies to generate the cache and .pnp.cjs
yarn install
To enable Zero-Installs, update your .gitignore to ensure the cache is tracked. You should not ignore the .yarn/cache directory:
# .gitignore
.yarn/cache
.pnp.cjs
.yarn/install-state.gz
# Still ignore the actual node_modules if any are generated by legacy tools
node_modules
Verification: To test this, clone your repository into a fresh directory. Instead of running yarn install, immediately run your start script (e.g., yarn start). If the application boots, your Zero-Install configuration is working.
The Trade-offs of a No-Module World
While the speed gains in CI/CD are massive, PnP is a fundamental shift that introduces specific frictions:
- Tooling Compatibility: Some tools (like certain Webpack loaders or ESLint plugins) expect a physical
node_modulespath. You may need to install the@yarnpkg/sdksto provide the necessary wrappers for VS Code or IntelliJ to handle type-checking and autocomplete. - Repo Size: While zip files are efficient, your Git history will grow faster because every dependency version bump adds new binary files to the repository.
- Strictness: PnP forbids phantom dependencies. If a package you use relies on a peer dependency that you haven't explicitly listed, your build will fail. While this is technically "correct" engineering, it can lead to a cycle of adding missing dependencies to
package.jsonfor legacy libraries.
Decision Matrix: Should You Switch?
| Scenario | Standard node_modules | Yarn Zero-Installs |
|---|---|---|
| CI Pipeline Speed | Slow (Network + I/O) | Instant (Disk Read) |
| Dependency Safety | Permissive (Phantom deps) | Strict (Explicit deps) |
| IDE Setup | Out-of-the-box | Requires SDK installation |
| Disk Usage | High (Duplicated files) | Low (Compressed zips) |
Closing Action
If your team spends more than five minutes per PR waiting for npm install or yarn install in your CI pipeline, Zero-Installs is worth the migration. Start by enabling PnP in a feature branch, install the Yarn SDKs for your IDE, and verify that your build pipeline can run without an explicit install step.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.