nvm-sh / nvm

· Source: Github Trending: All languages · Field: Technology & Digital — Software Development & Engineering, Cloud Computing & IT Infrastructure · Depth: Intermediate, extended

Summary

Node Version Manager (nvm) is a per-user, per-shell command-line tool designed to install and manage multiple Node.js versions on POSIX-compliant shells across Unix, macOS, and Windows WSL. The current supported version is v0.40.4. Installation typically involves a cURL or Wget script that clones the nvm repository to `~/.nvm` and configures shell profile files like `~/.bashrc`. Users can install specific Node.js versions (e.g., `nvm install 16`), set default versions, manage aliases, and migrate global npm packages between Node.js versions using flags like `--reinstall-packages-from` and `--latest-npm`. Nvm also supports `.nvmrc` files for automatic version switching based on directory context and offers specific installation guidance for Docker environments and Alpine Linux, which requires additional build tools due to its `musl` C/C++ stack.

Key takeaway

For DevOps Engineers managing Node.js environments, nvm streamlines version control, especially in CI/CD pipelines and Docker. You should integrate `.nvmrc` files into project repositories to ensure consistent Node.js versions across development and deployment, reducing "works on my machine" issues. Leverage nvm's `--reinstall-packages-from` and `--latest-npm` flags to simplify package migration when updating Node.js versions, ensuring dependencies remain compatible and up-to-date.

Key insights

Nvm simplifies managing multiple Node.js versions across various development environments and shells.

Principles

Method

Install nvm via a shell script, then use `nvm install <version>` to add Node.js versions. Switch versions with `nvm use <version>` or automatically via `.nvmrc` files in project directories.

In practice

Topics

Code references

Best for: Software Engineer, DevOps Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Github Trending: All languages.