nvm keeps "forgetting" node in new terminal session

Matheus Mello
Matheus Mello
September 2, 2023
Cover Image for nvm keeps "forgetting" node in new terminal session

Why "nvm" keeps "forgetting" node in a new terminal session in OS X?

So you're using nvm (Node Version Manager) in OS X, but every time you open a new terminal session, it forgets the node version you previously set. 🤔 It can be frustrating to constantly have to reselect the node version you want to use. But don't worry, we've got you covered! In this blog post, we'll explore common issues and provide easy solutions to this problem.

The Symptoms:

Let's start by understanding the symptoms of the issue. When you run nvm ls in your terminal, it should display a list of installed node versions, like this:

.nvm
 v0.11.12
 v0.11.13

However, when you open a new terminal session, it defaults to nothing, indicating that nvm forgot the selected node version:

.nvm
 v0.11.12
->   v0.11.13

Possible Causes:

There could be a few reasons why nvm is forgetting the selected node version. Let's explore common causes and their solutions:

1. Incorrect Shell Configuration:

The .profile or .bashrc file manages your terminal session's configuration. It's possible that the configuration for nvm is not set correctly in these files.

Solution:

First, locate the configuration file being used. Typically, it can be either ~/.profile, ~/.bashrc, or ~/.bash_profile. Open the file using a text editor and ensure that the configuration is present and set correctly.

For example, if you installed nvm using Homebrew, the configuration might look like this:

# nvm
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

If you installed nvm using the official installation script, the configuration might look like this:

# nvm
export NVM_DIR="/Users/farhad/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

Make sure you save the changes after editing the configuration file and then restart your terminal.

2. Multiple Shell Configurations:

If you have multiple shell configurations conflicting with each other, it can lead to nvm forgetting the selected node version.

Solution:

Check if you have multiple shell configurations, such as both .bashrc and .bash_profile, which might be causing conflicts. Consolidate your shell configurations into a single file (usually .bashrc or .bash_profile) and remove any duplicates or conflicting entries related to nvm. Save the changes and restart your terminal.

3. Incorrect Installation or Version:

If you initially installed nvm incorrectly or have an outdated version, it could cause issues with remembering the selected node version.

Solution:

To ensure you have the latest version of nvm, it is recommended to reinstall it following the official installation instructions. You can find the latest installation instructions on the nvm GitHub repository: https://github.com/nvm-sh/nvm

Wrap Up:

By following the solutions provided above, you should be able to resolve the issue of nvm "forgetting" the selected node version in a new terminal session. Remember to check your shell configuration, ensure you have a single shell configuration file, and consider reinstalling nvm if necessary.

If you're still facing issues or have any other questions, feel free to leave a comment below. Happy coding! 😊🚀

Take Your Tech Career to the Next Level

Our application tracking tool helps you manage your job search effectively. Stay organized, track your progress, and land your dream tech job faster.

Your Product
Product promotion

Share this article

More Articles You Might Like

Latest Articles

Cover Image for How can I echo a newline in a batch file?
batch-filenewlinewindows

How can I echo a newline in a batch file?

Published on March 20, 2060

🔥 💻 🆒 Title: "Getting a Fresh Start: How to Echo a Newline in a Batch File" Introduction: Hey there, tech enthusiasts! Have you ever found yourself in a sticky situation with your batch file output? We've got your back! In this exciting blog post, we

Cover Image for How do I run Redis on Windows?
rediswindows

How do I run Redis on Windows?

Published on March 19, 2060

# Running Redis on Windows: Easy Solutions for Redis Enthusiasts! 🚀 Redis is a powerful and popular in-memory data structure store that offers blazing-fast performance and versatility. However, if you're a Windows user, you might have stumbled upon the c

Cover Image for Best way to strip punctuation from a string
punctuationpythonstring

Best way to strip punctuation from a string

Published on November 1, 2057

# The Art of Stripping Punctuation: Simplifying Your Strings 💥✂️ Are you tired of dealing with pesky punctuation marks that cause chaos in your strings? Have no fear, for we have a solution that will strip those buggers away and leave your texts clean an

Cover Image for Purge or recreate a Ruby on Rails database
rakeruby-on-railsruby-on-rails-3

Purge or recreate a Ruby on Rails database

Published on November 27, 2032

# Purge or Recreate a Ruby on Rails Database: A Simple Guide 🚀 So, you have a Ruby on Rails database that's full of data, and you're now considering deleting everything and starting from scratch. Should you purge the database or recreate it? 🤔 Well, my