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

Support Corepack #181

Open
AlexWayfer opened this issue Sep 15, 2021 · 6 comments
Open

Support Corepack #181

AlexWayfer opened this issue Sep 15, 2021 · 6 comments

Comments

@AlexWayfer
Copy link
Contributor

Node.js 16.9 including Corepack: https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V16.md#2021-09-07-version-1690-current-targos

Its documentation says that I just can use pnpm, but I can't (with nodenv):

> nodenv install
Downloading node-v16.9.1-linux-x64.tar.gz...
-> https://nodejs.org/dist/v16.9.1/node-v16.9.1-linux-x64.tar.gz
Installing node-v16.9.1-linux-x64...
Installed node-v16.9.1-linux-x64 to /home/alex/.nodenv/versions/16.9.1

> pnpm i
nodenv: pnpm: command not found

The `pnpm' command exists in these Node versions:
  16.6.1
  16.7.0
@Ayc0
Copy link

Ayc0 commented Oct 17, 2021

I have a similar issue with running: corepack enable: I have this error: nodenv: corepack: command not found

@Pyrolistical
Copy link

looks like the corepack shim was added

@0xdevalias
Copy link

looks like the corepack shim was added

I'm using 1.4.0 and while I don't get an error while calling corepack, it doesn't actually seem to create any shims/etc that allow it to hijack npm/yarn/etc.

I can get around it by running corepack yarn --version, but that isn't ideal.

⇒  which -a yarn
/Users/devalias/.nodenv/shims/yarn
/usr/local/bin/yarn

⇒  which -a corepack
/Users/devalias/.nodenv/shims/corepack

⇒  nodenv --version
nodenv 1.4.0

⇒  yarn --version
1.22.19

⇒  corepack yarn --version
1.22.5

⇒  /Users/devalias/.nodenv/shims/yarn --version
1.22.5

⇒  /usr/local/bin/yarn --version
1.22.19

@jasonkarns
Copy link
Member

I haven't had much time recently, but will be looking into this soon.

I'm going to need to dive into the documentation but it seems that on a fresh node install, one needs to corepack enable, yes? Which creates shims for yarn and pnpm (only?).

So the presumption is that a) yarn and pnpm themselves are uninstalled first. If they exist, nodenv's shims will hit before getting to corepack's shims for them.

but more importantly, b) yarn and pnpm would need to be uninstalled across all nodes because nodenv's shim for yarn/pnpm exist if any node has them installed globally. (This is intentional! It is those very shims that must be invoked in order to direct the command to the appropriate node based on env-var/.node-version/etc.)

IOW, this might be tricky.

@yshrsmz
Copy link

yshrsmz commented Feb 12, 2023

Yes, corepack enable (and explicit corepack enable npm for npm) is needed IIUC(and is still in the experimental stage).
https://nodejs.org/api/corepack.html#enabling-the-feature

nodenv installs each version separately, so personally, I think it's kind of natural that one needs to call corepack enable for each instance of node.js.

@0xdevalias
Copy link

nodenv installs each version separately, so personally, I think it's kind of natural that one needs to call corepack enable for each instance of node.js

That would also be how I would expect the behaviour to be.

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

6 participants