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

Corepack enable does not symlink to npm.js #138

Open
wmertens opened this issue Jun 30, 2022 · 10 comments
Open

Corepack enable does not symlink to npm.js #138

wmertens opened this issue Jun 30, 2022 · 10 comments

Comments

@wmertens
Copy link

Is this an oversight or on purpose?

@merceyz
Copy link
Member

merceyz commented Jun 30, 2022

On purpose, see https://github.com/nodejs/corepack/tree/2470f58b74491a1301221df643c55be5adf1d349#corepack-enable--name

@wmertens
Copy link
Author

Ah ok. Still, adding it by default ensures that the correct npm version is used? Is that not desirable?

@arcanis
Copy link
Contributor

arcanis commented Jun 30, 2022

For the MVP we decided to leave it up to the npm project to decide whether they want Corepack to affect their binary by default or not. At the moment they didn't request it. If that's something you think would be a good idea, I think it'd be fair to raise the topic to them - I'm not aware of a public discussion yet 🤔

@wmertens
Copy link
Author

wmertens commented Jun 30, 2022

I'd even go so far as to expect that npm is actually calling corepack by default, since Node ships with both.

I opened npm/cli#5109

@Jack-Works
Copy link
Contributor

Jack-Works commented Jul 1, 2022

If we allowing this, we can use it to use npm v6 for projects that don't want to upgrade lockfile to v2.

e.g.:

https://github.com/microsoft/TypeScript/blob/f8aa570b23bd094798a98cef307038b1da9101a7/package.json#L31

"packageManager": "npm@6.14.15",

This does not work.

And NPM v7+ is annoying, it will upgrade and change the lockfile everytime but I cannot upgrade it. (See discussion in microsoft/TypeScript#49726 (comment))

@wmertens
Copy link
Author

wmertens commented Jul 1, 2022

@arcanis what would you consider as an official request from the npm team?

And for nodejs to ship with npm wrapped by corepack by default, what would need to happen?

@merceyz
Copy link
Member

merceyz commented Jul 1, 2022

@Jack-Works As the documentation mentions, you can explicitly enable it.

corepack enable npm

@aduh95
Copy link
Contributor

aduh95 commented Jul 4, 2022

And for nodejs to ship with npm wrapped by corepack by default, what would need to happen?

  1. Someone opens a PR on nodejs/node changing the defaults.
  2. The PR gets approved and receives no objections (that's obviously the most tricky part).
  3. The PR lands, and the following release of Node.js ships with npm wrapped by Corepack by default.

As long as Corepack has not reached version 1.0.0, such initiative is very unlikely to succeed. If the initiative is not supported by the npm team, it's also unlikely to succeed.

@ianldgs
Copy link

ianldgs commented Jul 11, 2022

I think because corepack is not symlinking to npm, when a project is configured to use another package manager, using npm does not throw error. That for me defeats the whole purpose of corepack...

  "packageManager": "yarn@3.2.1"
  • pnpm install -> Usage Error: This project is configured to use yarn
  • npm install -> works, would expect error

@Garfield550
Copy link

@Jack-Works As the documentation mentions, you can explicitly enable it.

corepack enable npm

This works for me.

> corepack prepare --all
Preparing npm@9.6.5...
Preparing pnpm@8.3.0...
Preparing yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447...

> corepack enable

> npm -v
9.5.1

> corepack enable npm

> npm -v
9.6.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants