Node version via package.json
Are you also tired of jumping from one project to another and sometimes you need nodejs 14, sometimes you need nodejs 16, and sometimes you need nodejs 18.
I feel the same way and I know it's just a command with nvm
or my personal favourite n
.
But what if you go into your project and the right node version is always there?
That was my wish too and I have fulfilled it.
What do you need#
- node (hope this is already installed)
- nvm or n
- zsh
- node-package-version
If you install my tool, you can get the right node version directly with npv fix.
Installation#
bash
npm install -g node-package-version
or
bash
yarn install -g node-package-version
Then simply add the following part to your .zshrc
:
bash
precmd(){ npv fix}
Now just press enter or open a new terminal in the project and the script runs and selects the correct node version.