{ "type": "module", "source": "doc/api/corepack.md", "introduced_in": "v14.19.0", "meta": { "added": [ "v16.9.0", "v14.19.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "miscs": [ { "textRaw": "Corepack", "name": "Corepack", "introduced_in": "v14.19.0", "type": "misc", "meta": { "added": [ "v16.9.0", "v14.19.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "desc": "

Corepack is an experimental tool to help with\nmanaging versions of your package managers. It exposes binary proxies for\neach supported package manager that, when called, will identify whatever\npackage manager is configured for the current project, transparently install\nit if needed, and finally run it without requiring explicit user interactions.

\n

This feature simplifies two core workflows:

\n", "miscs": [ { "textRaw": "Workflows", "name": "workflows", "modules": [ { "textRaw": "Enabling the feature", "name": "enabling_the_feature", "desc": "

Due to its experimental status, Corepack currently needs to be explicitly\nenabled to have any effect. To do that, run corepack enable, which\nwill set up the symlinks in your environment next to the node binary\n(and overwrite the existing symlinks if necessary).

\n

From this point forward, any call to the supported binaries will work\nwithout further setup. Should you experience a problem, run\ncorepack disable to remove the proxies from your system (and consider\nopening an issue on the Corepack repository to let us know).

", "type": "module", "displayName": "Enabling the feature" }, { "textRaw": "Configuring a package", "name": "configuring_a_package", "desc": "

The Corepack proxies will find the closest package.json file in your\ncurrent directory hierarchy to extract its \"packageManager\" property.

\n

If the value corresponds to a supported package manager, Corepack will make\nsure that all calls to the relevant binaries are run against the requested\nversion, downloading it on demand if needed, and aborting if it cannot be\nsuccessfully retrieved.

", "type": "module", "displayName": "Configuring a package" }, { "textRaw": "Upgrading the global versions", "name": "upgrading_the_global_versions", "desc": "

When running outside of an existing project (for example when running\nyarn init), Corepack will by default use predefined versions roughly\ncorresponding to the latest stable releases from each tool. Those versions can\nbe overridden by running the corepack prepare command along with the\npackage manager version you wish to set:

\n
corepack prepare yarn@x.y.z --activate\n
\n

Alternately, a tag or range may be used:

\n
corepack prepare pnpm@latest --activate\ncorepack prepare yarn@stable --activate\n
", "type": "module", "displayName": "Upgrading the global versions" }, { "textRaw": "Offline workflow", "name": "offline_workflow", "desc": "

Many production environments don't have network access. Since Corepack\nusually downloads the package manager releases straight from their registries,\nit can conflict with such environments. To avoid that happening, call the\ncorepack prepare command while you still have network access (typically at\nthe same time you're preparing your deploy image). This will ensure that the\nrequired package managers are available even without network access.

\n

The prepare command has various flags. Consult the detailed\nCorepack documentation for more information.

", "type": "module", "displayName": "Offline workflow" } ], "type": "misc", "displayName": "Workflows" }, { "textRaw": "Supported package managers", "name": "supported_package_managers", "desc": "

The following binaries are provided through Corepack:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Package managerBinary names
Yarnyarn, yarnpkg
pnpmpnpm, pnpx
", "type": "misc", "displayName": "Supported package managers" }, { "textRaw": "Common questions", "name": "common_questions", "modules": [ { "textRaw": "How does Corepack interact with npm?", "name": "how_does_corepack_interact_with_npm?", "desc": "

While Corepack could support npm like any other package manager, its\nshims aren't enabled by default. This has a few consequences:

\n", "type": "module", "displayName": "How does Corepack interact with npm?" }, { "textRaw": "Running `npm install -g yarn` doesn't work", "name": "running_`npm_install_-g_yarn`_doesn't_work", "desc": "

npm prevents accidentally overriding the Corepack binaries when doing a global\ninstall. To avoid this problem, consider one of the following options:

\n", "type": "module", "displayName": "Running `npm install -g yarn` doesn't work" } ], "type": "misc", "displayName": "Common questions" } ] } ] }