| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 99dbd8b commit 921041b
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,139 +12,10 @@ added: | |||
| 12 | 12 | ||
| 13 | 13 | > Stability: 1 - Experimental | |
| 14 | 14 | ||
| 15 | - _[Corepack][Corepack repository]_ is an experimental tool to help with | ||
| 16 | - managing versions of your package managers. It exposes binary proxies for | ||
| 17 | - each [supported package manager][] that, when called, will identify whatever | ||
| 18 | - package manager is configured for the current project, download it if needed, | ||
| 19 | - and finally run it. | ||
| 15 | + Documentation for this tool can be found on the [Corepack repository][]. | ||
| 20 | 16 | ||
| 21 | 17 | Despite Corepack being distributed with default installs of Node.js, the package | |
| 22 | - managers managed by Corepack are not part of the Node.js distribution and: | ||
| 18 | + managers managed by Corepack are not part of the Node.js distribution, and | ||
| 19 | + Corepack itself will no longer be distributed with future versions of Node.js. | ||
| 23 | 20 | ||
| 24 | - * Upon first use, Corepack downloads the latest version from the network. | ||
| 25 | - * Any required updates (related to security vulnerabilities or otherwise) are | ||
| 26 | - out of scope of the Node.js project. If necessary end users must figure out | ||
| 27 | - how to update on their own. | ||
| 28 | - | ||
| 29 | - This feature simplifies two core workflows: | ||
| 30 | - | ||
| 31 | - * It eases new contributor onboarding, since they won't have to follow | ||
| 32 | - system-specific installation processes anymore just to have the package | ||
| 33 | - manager you want them to. | ||
| 34 | - | ||
| 35 | - * It allows you to ensure that everyone in your team will use exactly the | ||
| 36 | - package manager version you intend them to, without them having to | ||
| 37 | - manually synchronize it each time you need to make an update. | ||
| 38 | - | ||
| 39 | - ## Workflows | ||
| 40 | - | ||
| 41 | - ### Enabling the feature | ||
| 42 | - | ||
| 43 | - Due to its experimental status, Corepack currently needs to be explicitly | ||
| 44 | - enabled to have any effect. To do that, run [`corepack enable`][], which | ||
| 45 | - will set up the symlinks in your environment next to the `node` binary | ||
| 46 | - (and overwrite the existing symlinks if necessary). | ||
| 47 | - | ||
| 48 | - From this point forward, any call to the [supported binaries][] will work | ||
| 49 | - without further setup. Should you experience a problem, run | ||
| 50 | - [`corepack disable`][] to remove the proxies from your system (and consider | ||
| 51 | - opening an issue on the [Corepack repository][] to let us know). | ||
| 52 | - | ||
| 53 | - ### Configuring a package | ||
| 54 | - | ||
| 55 | - The Corepack proxies will find the closest [`package.json`][] file in your | ||
| 56 | - current directory hierarchy to extract its [`"packageManager"`][] property. | ||
| 57 | - | ||
| 58 | - If the value corresponds to a [supported package manager][], Corepack will make | ||
| 59 | - sure that all calls to the relevant binaries are run against the requested | ||
| 60 | - version, downloading it on demand if needed, and aborting if it cannot be | ||
| 61 | - successfully retrieved. | ||
| 62 | - | ||
| 63 | - You can use [`corepack use`][] to ask Corepack to update your local | ||
| 64 | - `package.json` to use the package manager of your choice: | ||
| 65 | - | ||
| 66 | - ```bash | ||
| 67 | - corepack use pnpm@7.x # sets the latest 7.x version in the package.json | ||
| 68 | - corepack use yarn@* # sets the latest version in the package.json | ||
| 69 | - ``` | ||
| 70 | - | ||
| 71 | - ### Upgrading the global versions | ||
| 72 | - | ||
| 73 | - When running outside of an existing project (for example when running | ||
| 74 | - `yarn init`), Corepack will by default use predefined versions roughly | ||
| 75 | - corresponding to the latest stable releases from each tool. Those versions can | ||
| 76 | - be overridden by running the [`corepack install`][] command along with the | ||
| 77 | - package manager version you wish to set: | ||
| 78 | - | ||
| 79 | - ```bash | ||
| 80 | - corepack install --global yarn@x.y.z | ||
| 81 | - ``` | ||
| 82 | - | ||
| 83 | - Alternately, a tag or range may be used: | ||
| 84 | - | ||
| 85 | - ```bash | ||
| 86 | - corepack install --global pnpm@* | ||
| 87 | - corepack install --global yarn@stable | ||
| 88 | - ``` | ||
| 89 | - | ||
| 90 | - ### Offline workflow | ||
| 91 | - | ||
| 92 | - Many production environments don't have network access. Since Corepack | ||
| 93 | - usually downloads the package manager releases straight from their registries, | ||
| 94 | - it can conflict with such environments. To avoid that happening, call the | ||
| 95 | - [`corepack pack`][] command while you still have network access (typically at | ||
| 96 | - the same time you're preparing your deploy image). This will ensure that the | ||
| 97 | - required package managers are available even without network access. | ||
| 98 | - | ||
| 99 | - The `pack` command has [various flags][]. Consult the detailed | ||
| 100 | - [Corepack documentation][] for more information. | ||
| 101 | - | ||
| 102 | - ## Supported package managers | ||
| 103 | - | ||
| 104 | - The following binaries are provided through Corepack: | ||
| 105 | - | ||
| 106 | - | Package manager | Binary names | | ||
| 107 | - | --------------- | ----------------- | | ||
| 108 | - | [Yarn][] | `yarn`, `yarnpkg` | | ||
| 109 | - | [pnpm][] | `pnpm`, `pnpx` | | ||
| 110 | - | ||
| 111 | - ## Common questions | ||
| 112 | - | ||
| 113 | - ### How does Corepack interact with npm? | ||
| 114 | - | ||
| 115 | - While Corepack could support npm like any other package manager, its | ||
| 116 | - shims aren't enabled by default. This has a few consequences: | ||
| 117 | - | ||
| 118 | - * It's always possible to run a `npm` command within a project configured to | ||
| 119 | - be used with another package manager, since Corepack cannot intercept it. | ||
| 120 | - | ||
| 121 | - * While `npm` is a valid option in the [`"packageManager"`][] property, the | ||
| 122 | - lack of shim will cause the global npm to be used. | ||
| 123 | - | ||
| 124 | - ### Running `npm install -g yarn` doesn't work | ||
| 125 | - | ||
| 126 | - npm prevents accidentally overriding the Corepack binaries when doing a global | ||
| 127 | - install. To avoid this problem, consider one of the following options: | ||
| 128 | - | ||
| 129 | - * Don't run this command; Corepack will provide the package manager | ||
| 130 | - binaries anyway and will ensure that the requested versions are always | ||
| 131 | - available, so installing the package managers explicitly isn't needed. | ||
| 132 | - | ||
| 133 | - * Add the `--force` flag to `npm install`; this will tell npm that it's fine to | ||
| 134 | - override binaries, but you'll erase the Corepack ones in the process. (Run | ||
| 135 | - [`corepack enable`][] to add them back.) | ||
| 136 | - | ||
| 137 | - [Corepack documentation]: https://github.com/nodejs/corepack#readme | ||
| 138 | 21 | [Corepack repository]: https://github.com/nodejs/corepack | |
| 139 | - [Yarn]: https://yarnpkg.com | ||
| 140 | - [`"packageManager"`]: packages.md#packagemanager | ||
| 141 | - [`corepack disable`]: https://github.com/nodejs/corepack#corepack-disable--name | ||
| 142 | - [`corepack enable`]: https://github.com/nodejs/corepack#corepack-enable--name | ||
| 143 | - [`corepack install`]: https://github.com/nodejs/corepack#corepack-install--g--global---all--nameversion | ||
| 144 | - [`corepack pack`]: https://github.com/nodejs/corepack#corepack-pack---all--nameversion | ||
| 145 | - [`corepack use`]: https://github.com/nodejs/corepack#corepack-use-nameversion | ||
| 146 | - [`package.json`]: packages.md#nodejs-packagejson-field-definitions | ||
| 147 | - [pnpm]: https://pnpm.io | ||
| 148 | - [supported binaries]: #supported-package-managers | ||
| 149 | - [supported package manager]: #supported-package-managers | ||
| 150 | - [various flags]: https://github.com/nodejs/corepack#utility-commands | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,6 @@ | |||
| 21 | 21 | * [Cluster](cluster.md) | |
| 22 | 22 | * [Command-line options](cli.md) | |
| 23 | 23 | * [Console](console.md) | |
| 24 | - * [Corepack](corepack.md) | ||
| 25 | 24 | * [Crypto](crypto.md) | |
| 26 | 25 | * [Debugger](debugger.md) | |
| 27 | 26 | * [Deprecated APIs](deprecations.md) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -258,21 +258,6 @@ For completeness there is also `--input-type=commonjs`, for explicitly running | |||
| 258 | 258 | string input as CommonJS. This is the default behavior if `--input-type` is | |
| 259 | 259 | unspecified. | |
| 260 | 260 | ||
| 261 | - ## Determining package manager | ||
| 262 | - | ||
| 263 | - > Stability: 1 - Experimental | ||
| 264 | - | ||
| 265 | - While all Node.js projects are expected to be installable by all package | ||
| 266 | - managers once published, their development teams are often required to use one | ||
| 267 | - specific package manager. To make this process easier, Node.js ships with a | ||
| 268 | - tool called [Corepack][] that aims to make all package managers transparently | ||
| 269 | - available in your environment - provided you have Node.js installed. | ||
| 270 | - | ||
| 271 | - By default Corepack won't enforce any specific package manager and will use | ||
| 272 | - the generic "Last Known Good" versions associated with each Node.js release, | ||
| 273 | - but you can improve this experience by setting the [`"packageManager"`][] field | ||
| 274 | - in your project's `package.json`. | ||
| 275 | - | ||
| 276 | 261 | ## Package entry points | |
| 277 | 262 | ||
| 278 | 263 | In a package's `package.json` file, two fields can define entry points for a | |
@@ -904,8 +889,6 @@ The following fields in `package.json` files are used in Node.js: | |||
| 904 | 889 | by package managers as the name of the package. | |
| 905 | 890 | * [`"main"`][] - The default module when loading the package, if exports is not | |
| 906 | 891 | specified, and in versions of Node.js prior to the introduction of exports. | |
| 907 | - * [`"packageManager"`][] - The package manager recommended when contributing to | ||
| 908 | - the package. Leveraged by the [Corepack][] shims. | ||
| 909 | 892 | * [`"type"`][] - The package type determining whether to load `.js` files as | |
| 910 | 893 | CommonJS or ES modules. | |
| 911 | 894 | * [`"exports"`][] - Package exports and conditional exports. When present, | |
@@ -970,33 +953,6 @@ via `require()`](modules.md#folders-as-modules). | |||
| 970 | 953 | require('./path/to/directory'); | |
| 971 | 954 | ``` | |
| 972 | 955 | ||
| 973 | - ### `"packageManager"` | ||
| 974 | - | ||
| 975 | - <!-- YAML | ||
| 976 | - added: | ||
| 977 | - - v16.9.0 | ||
| 978 | - - v14.19.0 | ||
| 979 | - --> | ||
| 980 | - | ||
| 981 | - > Stability: 1 - Experimental | ||
| 982 | - | ||
| 983 | - * Type: {string} | ||
| 984 | - | ||
| 985 | - ```json | ||
| 986 | - { | ||
| 987 | - "packageManager": "<package manager name>@<version>" | ||
| 988 | - } | ||
| 989 | - ``` | ||
| 990 | - | ||
| 991 | - The `"packageManager"` field defines which package manager is expected to be | ||
| 992 | - used when working on the current project. It can be set to any of the | ||
| 993 | - [supported package managers][], and will ensure that your teams use the exact | ||
| 994 | - same package manager versions without having to install anything else other than | ||
| 995 | - Node.js. | ||
| 996 | - | ||
| 997 | - This field is currently experimental and needs to be opted-in; check the | ||
| 998 | - [Corepack][] page for details about the procedure. | ||
| 999 | - | ||
| 1000 | 956 | ### `"type"` | |
| 1001 | 957 | ||
| 1002 | 958 | <!-- YAML | |
@@ -1136,7 +1092,6 @@ This field defines [subpath imports][] for the current package. | |||
| 1136 | 1092 | ||
| 1137 | 1093 | [CommonJS]: modules.md | |
| 1138 | 1094 | [Conditional exports]: #conditional-exports | |
| 1139 | - [Corepack]: corepack.md | ||
| 1140 | 1095 | [ES module]: esm.md | |
| 1141 | 1096 | [ES modules]: esm.md | |
| 1142 | 1097 | [Node.js documentation for this section]: https://github.com/nodejs/node/blob/HEAD/doc/api/packages.md#conditions-definitions | |
@@ -1147,7 +1102,6 @@ This field defines [subpath imports][] for the current package. | |||
| 1147 | 1102 | [`"imports"`]: #imports | |
| 1148 | 1103 | [`"main"`]: #main | |
| 1149 | 1104 | [`"name"`]: #name | |
| 1150 | - [`"packageManager"`]: #packagemanager | ||
| 1151 | 1105 | [`"type"`]: #type | |
| 1152 | 1106 | [`--conditions` / `-C` flag]: #resolving-user-conditions | |
| 1153 | 1107 | [`--no-addons` flag]: cli.md#--no-addons | |
@@ -1162,7 +1116,6 @@ This field defines [subpath imports][] for the current package. | |||
| 1162 | 1116 | [self-reference]: #self-referencing-a-package-using-its-name | |
| 1163 | 1117 | [subpath exports]: #subpath-exports | |
| 1164 | 1118 | [subpath imports]: #subpath-imports | |
| 1165 | - [supported package managers]: corepack.md#supported-package-managers | ||
| 1166 | 1119 | [the dual CommonJS/ES module packages section]: #dual-commonjses-module-packages | |
| 1167 | 1120 | [the full specifier path]: esm.md#mandatory-file-extensions | |
| 1168 | 1121 | [the package examples repository]: https://github.com/nodejs/package-examples | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,7 +45,7 @@ const linkedHtmls = [...new Set(links)].map((link) => link.match(re)[1]) | |||
| 45 | 45 | const expectedJsons = linkedHtmls | |
| 46 | 46 | .map((name) => name.replace('.html', '.json')); | |
| 47 | 47 | const expectedDocs = linkedHtmls.concat(expectedJsons); | |
| 48 | - const renamedDocs = ['policy.json', 'policy.html']; | ||
| 48 | + const renamedDocs = ['corepack.json', 'corepack.html', 'policy.json', 'policy.html']; | ||
| 49 | 49 | const skipedDocs = ['quic.json', 'quic.html']; | |
| 50 | 50 | ||
| 51 | 51 | // Test that all the relative links in the TOC match to the actual documents. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments