"Fossies" - the Fresh Open Source Software Archive

Member "node-v19.8.1-win-x64/node_modules/corepack/README.md" (5 Nov 2022, 9378 Bytes) of package /windows/www/node-v19.8.1-win-x64.zip:

As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.


Corepack is a zero-runtime-dependency Node.js script that acts as a bridge between Node.js projects and the package managers they are intended to be used with during development. In practical terms, Corepack will let you use Yarn and pnpm without having to install them - just like what currently happens with npm, which is shipped by Node.js by default.

Important: At the moment, Corepack only covers Yarn and pnpm. Given that we have little control on the npm project, we prefer to focus on the Yarn and pnpm use cases. As a result, Corepack doesn’t have any effect at all on the way you use npm.

How to Install

Default Installs

Corepack is distributed by default with Node.js 14.19.0 and 16.9.0, but is opt-in for the time being. Run corepack enable to install the required shims.

Manual Installs

Click here to see how to install Corepack using npm

First uninstall your global Yarn and pnpm binaries (just leave npm). In general, you’d do this by running the following command:

npm uninstall -g yarn pnpm

# That should be enough, but if you installed Yarn without going through npm it might
# be more tedious - for example, you might need to run `brew uninstall yarn` as well.

Then install Corepack:

npm install -g corepack

We do acknowledge the irony and overhead of using npm to install Corepack, which is at least part of why the preferred option is to use the Corepack version that is distributed along with Node.js itself.


When Building Packages

Just use your package managers as you usually would. Run yarn install in Yarn projects, pnpm install in pnpm projects, and npm in npm projects. Corepack will catch these calls, and depending on the situation:

When Authoring Packages

Set your package’s manager with the packageManager field in package.json:

  "packageManager": "yarn@3.2.3+sha224.953c8233f7a92884eee2de69a1b92d1f2ec1655e66d08071ba9a02fa"

Here, yarn is the name of the package manager, specified at version 3.2.3, along with the SHA-224 hash of this version for validation. packageManager@x.y.z is required. The hash is optional but strongly recommended as a security practice. Permitted values for the package manager are yarn, npm, and pnpm.

Known Good Releases

When running Corepack within projects that don’t list a supported package manager, it will default to a set of Known Good Releases. In a way, you can compare this to Node.js, where each version ships with a specific version of npm.

If there is no Known Good Release for the requested package manager, Corepack looks up the npm registry for the latest available version and cache it for future use.

The Known Good Releases can be updated system-wide using the --activate flag from the corepack prepare and corepack hydrate commands.

Offline Workflow

The utility commands detailed in the next section.

Utility Commands

corepack <binary name>[@<version>] [... args]

This meta-command runs the specified package manager in the local folder. You can use it to force an install to run with a given version, which can be useful when looking for regressions.

Note that those commands still check whether the local project is configured for the given package manager (ie you won’t be able to run corepack yarn install on a project where the packageManager field references pnpm).

corepack enable [... name]

Option Description
--install-directory Add the shims to the specified location

This command will detect where Node.js is installed and will create shims next to it for each of the specified package managers (or all of them if the command is called without parameters). Note that the npm shims will not be installed unless explicitly requested, as npm is currently distributed with Node.js through other means.

corepack disable [... name]

Option Description
--install-directory Remove the shims to the specified location

This command will detect where Node.js is installed and will remove the shims from there.

corepack prepare [... name@version]

Option Description
--all Prepare the “Last Known Good” version of all supported package managers
-o,--output Also generate an archive containing the package managers
--activate Also update the “Last Known Good” release

This command will download the given package managers (or the one configured for the local project if no argument is passed in parameter) and store it within the Corepack cache. If the -o,--output flag is set (optionally with a path as parameter), an archive will also be generated that can be used by the corepack hydrate command.

corepack hydrate <path/to/corepack.tgz>

Option Description
--activate Also update the “Last Known Good” release

This command will retrieve the given package manager from the specified archive and will install it within the Corepack cache, ready to be used without further network interaction.

Environment Variables




See DESIGN.md.

License (MIT)