-
Notifications
You must be signed in to change notification settings - Fork 260
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
Usage with Corepack #1200
Comments
Hi @JanJakes, thanks for reporting! This is ultimately a duplicate of #987 (though as you say, the solution likely won't involve needing to install corepack directly). There's a bit of complication around the error messaging, since we want to maintain our helpful error messages and not leave something unhelpful like "Command not found" in the case where we pass-through but don't actually use the underlying corepack shim. |
Hi @charlespierce! Thanks for your response. It definitely looks like a related issue, although my scenario maybe adds some more context. The related pull request seems to handle this for the I'm also not sure what are the plans for handling this — whether Volta wants to use corepack always when available or if it's up to us users to declare something like |
I've ended up automating this a bit more with the following script:
#!/bin/bash
bins=("corepack" "npm" "npx" "pnpm" "pnpx" "yarn" "yarnpkg")
for bin in "${bins[@]}"; do
path="$HOME/.volta/bin/$bin"
rm -f "$path"
echo '#!/bin/bash' > "$path"
echo 'DIR="$(dirname "$0")"' >> "$path"
echo 'NODE_VERSION="$(node --version)"' >> "$path"
echo '"$DIR/../tools/image/node/${NODE_VERSION:1}/bin/'"$bin"'" "$@"' >> "$path"
chmod +x "$path"
done
|
With Corepack included in NodeJS versions 14.19+, 16.19+, and 17+, some of us may want to use Volta for NodeJS version management only and leave package manager binaries to Corepack.
However, that doesn't seem to be doable at the moment as Volta doesn't expose the
corepack
binary, nor those it manages.See an example and a complete reproduction below.
Corepack binary is not exposed:
We can fix that by doing something along these lines:
Now Corepack works:
$ corepack enable
But the binaries Corepack manages are not exposed:
We could fix it again as with Corepack:
Now it works:
But we'd need to do that for all the binaries managed by Corepack (npm, npx, pnpm, pnpx, yarn, yarnpkg), and some of these are already taken by Volta.
Could Volta proxy to the above-mentioned commands by default? I guess it should be an easy fix.
Thanks!
The text was updated successfully, but these errors were encountered: