NVM Shows Twice in Debian (ProxMox)

Abstract: Resolve duplicate NVM entries in Debian Proxmox by consolidating initialization into .bashrc and removing redundant commands from .profile.

Created: 2026-08-21 by
NVM appearing twice in your Debian environment typically stems from conflicting shell initialization files, specifically when both .bashrc and .profile (or .bash_profile) contain source commands for the nvm script. This duplication causes the shell to load the NVM environment multiple times during session startup, leading to confusion and potential conflicts in variable definitions. Resolving this requires auditing your dotfiles to ensure NVM is initialized exactly once per shell type.

Understanding Shell Initialization Order

To fix duplicate NVM entries, you must first understand how Bash loads configuration files. When you open a terminal, it usually starts as an interactive login shell or a non-login interactive shell. The behavior differs slightly between Proxmox VE host systems and standard Debian installations, but the core logic remains consistent. For an interactive login shell (such as when you SSH in or start a new console session), Bash reads ~/.bash_profile, ~/.bash_login, and ~/.profile in that order, executing only the first one it finds. It does not read ~/.bashrc automatically unless explicitly sourced from one of those files. For an interactive non-login shell (such as opening a new tab in a GUI terminal emulator), Bash reads ~/.bashrc. If you have placed the NVM initialization code in both ~/.bashrc and ~/.profile, you might see it load twice depending on how your shell transitions between states or if you manually source files.

Identifying the Conflict

The most common scenario involves users copying NVM installation instructions that suggest adding lines to ~/.bashrc. However, many Linux distributions also link ~/.profile to ~/.bashrc or vice versa, or users manually add sourcing commands to both. Check your home directory for these files:
  • ~/.bashrc
  • ~/.profile
  • ~/.bash_profile
Open each file and search for the string nvm. You are looking for lines similar to export NVM_DIR="$HOME/.nvm" followed by [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh". If this block appears in more than one file, or if one file sources another which contains the same block, you have found the root cause.

Step-by-Step Resolution

Follow these steps to consolidate your NVM initialization into a single location. We recommend keeping the initialization in ~/.bashrc because it applies to all interactive shells, ensuring NVM is available regardless of how you log in.
  1. Backup your configuration files: Before making changes, create backups to prevent data loss.
    cp ~/.bashrc ~/.bashrc.backup
    cp ~/.profile ~/.profile.backup
  2. Edit ~/.bashrc: Open the file in your preferred text editor.
    nano ~/.bashrc
    Ensure the NVM initialization block is present at the end of the file. It should look like this:
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
    If it is already there, proceed to the next step. If not, append it.
  3. Remove duplicates from other files: Open ~/.profile and ~/.bash_profile.
    nano ~/.profile
    If you find the NVM initialization block here, remove it. Your ~/.profile should ideally source ~/.bashrc to ensure consistency, so check if it contains:
    # if running bash
    if [ -n "$BASH_VERSION" ]; then
        # include .bashrc if it exists
        if [ -f "$HOME/.bashrc" ]; then
    	. "$HOME/.bashrc"
        fi
    fi
    This ensures that login shells also pick up the settings from .bashrc, including NVM.
  4. Verify no other scripts interfere: Some Proxmox configurations or custom scripts might source files dynamically. Check /etc/profile and /etc/bash.bashrc for any global NVM references, though this is rare for user-specific tools like NVM.
After editing, apply the changes by restarting your terminal or running source ~/.bashrc. To verify the fix, run nvm --version. If it returns a version number without errors or duplicate messages, the issue is resolved.

Proxmox Specific Considerations

When managing Debian VMs within Proxmox, remember that the host system and the guest OS have separate environments. The NVM issue occurs entirely within the Debian guest. If you are accessing the VM via the Proxmox web interface's console, it acts as a direct TTY, often triggering login shell behavior. If you SSH into the VM, it may behave differently depending on your SSH client configuration. Ensure that your SSH key authentication and network settings are correct. For related issues with connectivity or access, such as resetting credentials or troubleshooting SSH handshake errors, refer to our guide on How to Reset Root Password for a VM Running on Proxmox and Troubleshooting kex_exchange_identification Error in Linux SSH Connection. These resources can help if you suspect broader configuration issues alongside the NVM duplication.

Common Pitfalls

Even after fixing the initialization files, some users encounter residual issues. Ensure you are not using aliases that redefine nvm or npm. Check your ~/.aliases file if you use one. Additionally, avoid installing Node.js via apt while using NVM, as they can conflict. NVM manages its own Node versions in ~/.nvm/versions/node. Using apt installed Node can override the path set by NVM, causing confusion about which version is active. Always verify your current Node version with node -v and your NVM status with nvm ls. If nvm ls shows multiple "default" arrows or strange paths, clean up your ~/.nvm/alias/default file to point to a single version.

Frequently Asked Questions

Why does NVM still show twice after editing .bashrc?

If you see duplicate outputs, check if you are sourcing .bashrc multiple times within the file itself or if another script in your PATH is calling it. Use echo $NVM_DIR to verify if the variable is being redefined. Clearing your shell history and starting a fresh terminal instance can also help rule out cached state issues.

Can I use NVM with Zsh instead of Bash?

Yes, but you must configure it for Zsh specifically. Instead of modifying .bashrc, you need to add the NVM initialization lines to ~/.zshrc. The syntax is identical, but the file location differs. Ensure you do not mix Bash and Zsh configuration files, as they are not compatible.

Does NVM affect the Proxmox host system?

No, NVM installed inside a Debian VM only affects that specific virtual machine. The Proxmox host runs its own Debian-based OS and has separate environment variables. Changes made to .bashrc inside the VM will never impact the host's shell configuration or installed packages.

How do I completely uninstall NVM to start over?

To remove NVM, delete the ~/.nvm directory, remove the initialization lines from ~/.bashrc and ~/.profile, and delete any associated symlinks in /usr/local/bin created by npm. Then restart your shell. This provides a clean slate for reinstallation.

What if I need different Node versions for different projects?

NVM allows you to set local versions per directory using nvm use or by creating a .nvmrc file in your project root. This feature works independently of the shell initialization fix. Once NVM is loaded correctly once, you can switch versions seamlessly without worrying about duplicate definitions.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More