how to/is it possible to add a define a explicit shim/tool #4300
Replies: 2 comments 2 replies
-
I've just explored hooks as a possibility - adding
there are two problems with that. the enter hook doesn't appear to get triggered unless experimental is globally enabled (thats manageable) The alias doesn't work :-( I suspect its due to the way mise adds tool paths trumping the alias but im not sure how to validate that. |
Beta Was this translation helpful? Give feedback.
-
i've actually managed to get a workable solution to this problem, and it wasn't what i was expecting :-) Solution: don't use corepack (Corepack as a tool to manager package managers, is clashing with mise, a tool to manage tools) Here's what i have ended up with [tools]
node = "22" # node must be specified before "npm:npm" - else npm from node takes precedence
"npm:npm" = ">=11" # need at least version 11
"npm:pnpm" = ">=10" # package manager of choice
[settings]
# not required, but a good place to point out that the solution describe here wont work if you required idiomatic
# tool version of node from .nvmrc - as thats always added to path after `[tools]` and thus takes precedence always
idiomatic_version_file_disable_tools = ["node"] package json "devEngines": {
"packageManager": {
"name": "pnpm",
"version": ">=10",
"onFail": "warn"
}
The only downside i've found is that i need to set onFail=warn - so that mise can still use npm to download tools. |
Beta Was this translation helpful? Give feedback.
-
in node - there is a tool corepack - its future is in debate - but thats not the focus here.
When I run corepack enable, shims are added to the 'install' directory, for pnpm and yarn - then when attempting to use either of those, the correct version is downloaded according to the version defined in your package json. The shims pass through corepack to ensure that the correct package manager is chosen based on your preferences.
it seems straightforward enough - setup this:
(npm needs to be explicitly enabled)
but that gives an error
It looks as though it is struggling with the existing symlink of npm that is produced by mise.
Another suggested approach by corepack is to use an alias.
i tried this:
But i'm not seeing the alias
(is there a way i can reliably re-run the install for testing these things - currenty i
mise uninstall --all
thenmise install
but that seems overkill.)when i run
alias npm="corepack npm"
directly - it works as expected.So it got me wondering if i could use mise to setup an alias somehow - but i cant see any obvious way to do this without creating a plugin.
Beta Was this translation helpful? Give feedback.
All reactions