If youβve ever struggled with managing multiple Node.js versions or faced compatibility issues across projects, NVM (Node Version Manager) is your best friend.
In this guide, Iβll walk you through a simple, reliable way to install Node.js using NVM and get your project up and running smoothly.
π§ Step 1: Install NVM
Start by installing NVM using the official install script:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash
This command downloads and runs the installer directly from the official repository.
π§ Step 2: Load NVM (Without Restarting Terminal)
After installation, you donβt need to restart your terminal. Just run:
\. "$HOME/.nvm/nvm.sh"
This loads NVM into your current shell session.
π§ Step 3: Install Node.js
Now install the latest Node.js version (in this case, version 24):
nvm install 24
π§ Step 4: Use the Installed Version
Switch to the installed version:
nvm use 24
π§ Step 5: Verify Installation
Make sure everything is working:
node -v
npm -v
You should see something like:
v24.x.x
10.x.x
β οΈ Important: Make It Permanent
If you skip this step, NVM wonβt load automatically when you open a new terminal.
Add the following lines to your ~/.zshrc file:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Then reload your configuration:
touch ~/.zshrc
source ~/.zshrc
β Back to Your Project
Once Node.js is set up, you can return to your project and run:
cd nextjs-boilerplate
npm install
npm run dev
Your app should now start without any issues π
π‘ Final Thoughts
Using NVM gives you flexibility and control over your development environment. Whether you're switching between projects or testing different Node versions, it makes the process seamless.
If you're working with modern frameworks like Next.js, having the correct Node version can save you from a lot of headaches.
Happy coding! π
Top comments (0)