/usr/share/doc/nodejs/html/api
# Corepack <!-- introduced_in=v16.9.0 --> <!-- type=misc --> <!-- YAML added: - v16.9.0 - v14.19.0 --> > Stability: 1 - Experimental _[Corepack][]_ is an experimental tool to help with managing versions of your package managers. It exposes binary proxies for each [supported package manager][] that, when called, will identify whatever package manager is configured for the current project, transparently install it if needed, and finally run it without requiring explicit user interactions. This feature simplifies two core workflows: * It eases new contributor onboarding, since they won't have to follow system-specific installation processes anymore just to have the package manager you want them to. * It allows you to ensure that everyone in your team will use exactly the package manager version you intend them to, without them having to manually synchronize it each time you need to make an update. ## Workflows ### Enabling the feature Due to its experimental status, Corepack currently needs to be explicitly enabled to have any effect. To do that, run [`corepack enable`][], which will set up the symlinks in your environment next to the `node` binary (and overwrite the existing symlinks if necessary). From this point forward, any call to the [supported binaries][] will work without further setup. Should you experience a problem, run [`corepack disable`][] to remove the proxies from your system (and consider opening an issue on the [Corepack repository][] to let us know). ### Configuring a package The Corepack proxies will find the closest [`package.json`][] file in your current directory hierarchy to extract its [`"packageManager"`][] property. If the value corresponds to a [supported package manager][], Corepack will make sure that all calls to the relevant binaries are run against the requested version, downloading it on demand if needed, and aborting if it cannot be successfully retrieved. ### Upgrading the global versions When running outside of an existing project (for example when running `yarn init`), Corepack will by default use predefined versions roughly corresponding to the latest stable releases from each tool. Those versions can be overridden by running the [`corepack prepare`][] command along with the package manager version you wish to set: ```bash corepack prepare yarn@x.y.z --activate ``` ### Offline workflow Many production environments don't have network access. Since Corepack usually downloads the package manager releases straight from their registries, it can conflict with such environments. To avoid that happening, call the [`corepack prepare`][] command while you still have network access (typically at the same time you're preparing your deploy image). This will ensure that the required package managers are available even without network access. The `prepare` command has [various flags][]. Consult the detailed [Corepack documentation][] for more information. ## Supported package managers The following binaries are provided through Corepack: | Package manager | Binary names | | --------------- | ----------------- | | [Yarn][] | `yarn`, `yarnpkg` | | [pnpm][] | `pnpm`, `pnpx` | ## Common questions ### How does Corepack interact with npm? While Corepack could support npm like any other package manager, its shims aren't enabled by default. This has a few consequences: * It's always possible to run a `npm` command within a project configured to be used with another package manager, since Corepack cannot intercept it. * While `npm` is a valid option in the [`"packageManager"`][] property, the lack of shim will cause the global npm to be used. ### Running `npm install -g yarn` doesn't work npm prevents accidentally overriding the Corepack binaries when doing a global install. To avoid this problem, consider one of the following options: * Don't run this command; Corepack will provide the package manager binaries anyway and will ensure that the requested versions are always available, so installing the package managers explicitly isn't needed. * Add the `--force` flag to `npm install`; this will tell npm that it's fine to override binaries, but you'll erase the Corepack ones in the process. (Run [`corepack enable`][] to add them back.) [Corepack]: https://github.com/nodejs/corepack [Corepack documentation]: https://github.com/nodejs/corepack#readme [Corepack repository]: https://github.com/nodejs/corepack [Yarn]: https://yarnpkg.com [`"packageManager"`]: packages.md#packagemanager [`corepack disable`]: https://github.com/nodejs/corepack#corepack-disable--name [`corepack enable`]: https://github.com/nodejs/corepack#corepack-enable--name [`corepack prepare`]: https://github.com/nodejs/corepack#corepack-prepare--nameversion [`package.json`]: packages.md#nodejs-packagejson-field-definitions [pnpm]: https://pnpm.js.org [supported binaries]: #supported-package-managers [supported package manager]: #supported-package-managers [various flags]: https://github.com/nodejs/corepack#utility-commands
.
Edit
..
Edit
addons.html
Edit
addons.json
Edit
addons.md
Edit
all.html
Edit
all.json
Edit
assert.html
Edit
assert.json
Edit
assert.md
Edit
assets
Edit
async_context.html
Edit
async_context.json
Edit
async_context.md
Edit
async_hooks.html
Edit
async_hooks.json
Edit
async_hooks.md
Edit
buffer.html
Edit
buffer.json
Edit
buffer.md
Edit
child_process.html
Edit
child_process.json
Edit
child_process.md
Edit
cli.html
Edit
cli.json
Edit
cli.md
Edit
cluster.html
Edit
cluster.json
Edit
cluster.md
Edit
console.html
Edit
console.json
Edit
console.md
Edit
corepack.html
Edit
corepack.json
Edit
corepack.md
Edit
crypto.html
Edit
crypto.json
Edit
crypto.md
Edit
debugger.html
Edit
debugger.json
Edit
debugger.md
Edit
deprecations.html
Edit
deprecations.json
Edit
deprecations.md
Edit
dgram.html
Edit
dgram.json
Edit
dgram.md
Edit
diagnostics_channel.html
Edit
diagnostics_channel.json
Edit
diagnostics_channel.md
Edit
dns.html
Edit
dns.json
Edit
dns.md
Edit
documentation.html
Edit
documentation.json
Edit
documentation.md
Edit
domain.html
Edit
domain.json
Edit
domain.md
Edit
embedding.html
Edit
embedding.json
Edit
embedding.md
Edit
errors.html
Edit
errors.json
Edit
errors.md
Edit
esm.html
Edit
esm.json
Edit
esm.md
Edit
events.html
Edit
events.json
Edit
events.md
Edit
fs.html
Edit
fs.json
Edit
fs.md
Edit
globals.html
Edit
globals.json
Edit
globals.md
Edit
http.html
Edit
http.json
Edit
http.md
Edit
http2.html
Edit
http2.json
Edit
http2.md
Edit
https.html
Edit
https.json
Edit
https.md
Edit
index.html
Edit
index.json
Edit
index.md
Edit
inspector.html
Edit
inspector.json
Edit
inspector.md
Edit
intl.html
Edit
intl.json
Edit
intl.md
Edit
module.html
Edit
module.json
Edit
module.md
Edit
modules.html
Edit
modules.json
Edit
modules.md
Edit
n-api.html
Edit
n-api.json
Edit
n-api.md
Edit
net.html
Edit
net.json
Edit
net.md
Edit
os.html
Edit
os.json
Edit
os.md
Edit
packages.html
Edit
packages.json
Edit
packages.md
Edit
path.html
Edit
path.json
Edit
path.md
Edit
perf_hooks.html
Edit
perf_hooks.json
Edit
perf_hooks.md
Edit
permissions.html
Edit
permissions.json
Edit
permissions.md
Edit
policy.html
Edit
policy.json
Edit
policy.md
Edit
process.html
Edit
process.json
Edit
process.md
Edit
punycode.html
Edit
punycode.json
Edit
punycode.md
Edit
querystring.html
Edit
querystring.json
Edit
querystring.md
Edit
readline.html
Edit
readline.json
Edit
readline.md
Edit
repl.html
Edit
repl.json
Edit
repl.md
Edit
report.html
Edit
report.json
Edit
report.md
Edit
stream.html
Edit
stream.json
Edit
stream.md
Edit
string_decoder.html
Edit
string_decoder.json
Edit
string_decoder.md
Edit
synopsis.html
Edit
synopsis.json
Edit
synopsis.md
Edit
test.html
Edit
test.json
Edit
test.md
Edit
timers.html
Edit
timers.json
Edit
timers.md
Edit
tls.html
Edit
tls.json
Edit
tls.md
Edit
tracing.html
Edit
tracing.json
Edit
tracing.md
Edit
tty.html
Edit
tty.json
Edit
tty.md
Edit
url.html
Edit
url.json
Edit
url.md
Edit
util.html
Edit
util.json
Edit
util.md
Edit
v8.html
Edit
v8.json
Edit
v8.md
Edit
vm.html
Edit
vm.json
Edit
vm.md
Edit
wasi.html
Edit
wasi.json
Edit
wasi.md
Edit
webcrypto.html
Edit
webcrypto.json
Edit
webcrypto.md
Edit
webstreams.html
Edit
webstreams.json
Edit
webstreams.md
Edit
worker_threads.html
Edit
worker_threads.json
Edit
worker_threads.md
Edit
zlib.html
Edit
zlib.json
Edit
zlib.md
Edit