Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Mention possibility of corepack enable npm #53257

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions doc/api/corepack.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,31 +96,35 @@ it can conflict with such environments. To avoid that happening, call the
the same time you're preparing your deploy image). This will ensure that the
required package managers are available even without network access.

The `pack` command has [various flags][]. Consult the detailed
The `corepack` command has [various flags][]. Consult the detailed
JonnyBurger marked this conversation as resolved.
Show resolved Hide resolved
[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` |
| Package manager | Binary names |
| ---------------- | ----------------- |
| [Yarn][] | `yarn`, `yarnpkg` |
| [pnpm][] | `pnpm`, `pnpx` |
| [npm][]* | `npm`, `npx` |

\* Not enabled by default. Use `corepack enable npm` to do so.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is only referring to NPM, couldn't it be referenced by name, and not a "*"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could do that if you want me to.
Wanted to raise attention that it is a special case as soon as you read the entry in the table.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s your call, I’m not a CODEOWNER, so it’s up to you :-).


## 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:
The npm 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.

You can enable shimming npm by running `corepack enable npm`.

### Running `npm install -g yarn` doesn't work

npm prevents accidentally overriding the Corepack binaries when doing a global
Expand All @@ -145,6 +149,7 @@ install. To avoid this problem, consider one of the following options:
[`corepack use`]: https://github.com/nodejs/corepack#corepack-use-nameversion
[`package.json`]: packages.md#nodejs-packagejson-field-definitions
[pnpm]: https://pnpm.io
[npm]: https://npmjs.org
[supported binaries]: #supported-package-managers
[supported package manager]: #supported-package-managers
[various flags]: https://github.com/nodejs/corepack#utility-commands