fnm
fnm copied to clipboard
Better Corepack support
Corepack is an official Node.js tool for managing package managers like npm, pnpm, or Yarn. It has been bundled with Node.js versions since v16.9.
Instead of running npm i -g yarn
, you run corepack enable
. This places yarn
+ pnpm
binaries (technically they're Corepack shims) alongside the node
binary.
Unfortunately, switching to a new Node.js version with fnm requires you to run corepack enable
again before you can use your custom package managers.
Could a configuration option (ex. --corepack
) be added to automatically handle this for users?
Related: post-install hooks like in #139 could be used to run corepack enable
, although it might be good to have a dedicated option for Corepack since it's going to be a very common workflow for Node.js users
Would be nice if it could be run automatically - perhaps when detecting that the shims are already there?
Hi! sorry for the delay. I don't know corepack so much, so I'm sorry if my questions are stupid:
Unfortunately, switching to a new Node.js version with fnm requires you to run
corepack enable
again before you can use your custom package managers.
By switching to a new Node.js version
you mean a fresh version after installation, or after every fnm use
into a version that was already corepack enable
-d?
Could a configuration option (ex.
--corepack
) be added to automatically handle this for users?
Where would this configuration go?
-
fnm install --corepack
- we can also go with
fnm env --install-with-corepack
(and therefore emittingFNM_INSTALL_WITH_COREPACK=true
, which we can use infnm install
:smiley:)
I think my next question would be, why shouldn't it be the default? Will it hurt to call corepack enable
on all installation after a certain version?
Related: post-install hooks like in #139 could be used to run
corepack enable
intriguing. Maybe we can have a $FNM_DIR/hooks/
directory that can allow executables to be fired when fnm does something:
-
$FNM_DIR/hooks/post_install{,.sh,.cmd,.bat,.exe}
-
$FNM_DIR/hooks/post_use{,.sh,.cmd,.bat,.exe}
By
switching to a new Node.js version
you mean a fresh version after installation, or after everyfnm use
into a version that was alreadycorepack enable
-d?
After a fresh install.
Where would this configuration go?
fnm install --corepack
- we can also go with
fnm env --install-with-corepack
(and therefore emittingFNM_INSTALL_WITH_COREPACK=true
, which we can use infnm install
😃)
Both of these seem fine. Having fnm env --install-with-corepack
seems helpful since you won't need to repeat --corepack
over and over.
I think my next question would be, why shouldn't it be the default? Will it hurt to call
corepack enable
on all installation after a certain version?
Corepack is currently marked "Stability: 1 - Experimental" by Node.js and is explicitly opt-in because of this:
Due to its experimental status, Corepack currently needs to be explicitly enabled to have any effect.
Until it's more stable I don't think Corepack should be the default for fnm.
I think my next question would be, why shouldn't it be the default? Will it hurt to call
corepack enable
on all installation after a certain version?
I personally think it could be interesting!
The main reason why it's not the default yet isn't stability per-se (as in, I'm not aware of any bugs in it), but rather that it's a little difficult to evaluate the risks for the whole Node userbase. Enabling it by default for a smaller population (such as fnm users) would be a good way to gather confidence.
Friendly ping 😊
This would be extremely helpful in making it easier to onboard new developers to fnm