Skip to content

This notebook belongs to

Sadat Jubayer

Senior Software Engineer at Premio

If found, please return to hello@jubayer.dev

Vol. 7Seven years of building

Started
January 2020
Everyday tools
TypeScript, Vue, React, Next.js, NestJS, React Native
Education
B.Sc. CSSE, AIUB, 2020
2 min readDev Tool

Replace nvm with mise

Pin Node in mise.toml, let interactive zsh switch versions by directory, and run the same version from a script or CI.

You switch from an app that runs on Node 22 to one that runs on Node 24. An .nvmrc can record which version each app needs, but if you forget nvm use, your next command runs under the old version. With mise, record Node in the project and let your shell select it when you change directories.

Pin the version in the project

Install mise and make sure the executable is on your PATH. From the root of an app without an existing mise config, run these commands.

mise use --path ./mise.toml node@22.20.0
cat mise.toml

You get a mise.toml with a [tools] section and node = "22.20.0". The --path flag targets this file even if a parent directory has a mise config. mise use also installs that version if it is missing.

Commit the file so everyone can install the same version. Use the full version to request the same patch release across machines. A major-version request such as node@22 permits mise to resolve a patch version when someone installs it.

Let zsh select Node as you move

Put the activation line in ~/.zshrc or run it once in the current interactive shell to try it. The following commands assume you are in the app you just configured.

eval "$(mise activate zsh)"

Run node --version at the next prompt to see v22.20.0. Change into a second project that pins 24.11.1 and the same version command prints v24.11.1 there.

Once you have moved the projects you work on, remove the old nvm initialization and any auto-switch hook from your shell startup file, then start a fresh shell. If an unexpected version appears, compare command -v node with mise which node. The first shows the executable the shell found. The second shows which executable mise selected for the directory.

Run without an interactive prompt

For a fresh checkout, install the declared versions before running a command. For a script or CI, use mise exec to apply the project versions for that command without relying on your prompt.

mise install
mise exec -- node --version

The second command prints v22.20.0 when you run it from the first app.

If mise reports that it will not load a config because the file is untrusted, review the file and trust it only if you know its source. Then rerun the command from the directory that contains the config you meant to use.