![]() This ensures that you are always using the correct version of Node.js for your project without needing to manually switch versions every time you enter the directory. That's it! Now, whenever you enter your project's directory, the zsh-hook we defined in your ~/.zshrc file will automatically switch to the Node.js version specified in the project's. Restart your terminal or run source ~/.zshrc for the changes to take effect. Nvm install elif thenįi elif then echo "Reverting to nvm default version" vim ~/.zshrc).Īdd the following lines at the end of the. zshrc file in your favorite text editor (e.g. For example, if your project requires Node.js version 18.15.0, add 18.15.0 to the. nvmrc file and add the version of Node.js you want to use. In the root directory of your project, create a. ![]() Setting up auto-switchingĪssuming you have nvm and Zsh installed, here's how to set up auto-switching: If you don't have nvm installed, you can find instructions on the nvm GitHub page. Prerequisitesīefore we dive in, you'll need to have the following installed on your machine: In this post, I'll show you how to set up auto-switching using nvm and zsh. Fortunately, there's a way to automate switching to the correct Node.js version whenever you enter the project directory. Manually switching between versions can be tedious and easy to forget, especially if you're working on multiple projects simultaneously. How to automate switching Node.js versions with nvm and zshĪs a frontend developer, you may find yourself working on projects that require different versions of Node.js.
0 Comments
Leave a Reply. |