The Linux

Explore the Linux and Linux world.

Member-only story

NixOS + Nodejs

Managing Node.js Versions on NixOS: A Comprehensive Guide

Step-by-Step Tutorial to Manage Node Versions on NixOS.

Rajdeep Singh
The Linux
Published in
6 min readFeb 5, 2025

--

In NixOS, you install the specific Node.js version according to your requirements, such as Node.js version 18, 20, 21, 22, etc.

Check out the following example to install node.js in your NixOS.

# installing nodejs package in system profile.
environment.systemPackages = with pkgs; [ nodejs_23 ];
# nodejs_22
environment.systemPackages = with pkgs; [ nodejs_22 ];
# nodejs_20
environment.systemPackages = with pkgs; [ nodejs_20 ];

However, you can not install multiple node versions in NixOS. The following example explains this better.

environment.systemPackages = with pkgs; [ nodejs_22 nodejs_20 ]; # it not work.

The most effective method for installing the Node version in NixOS is to utilise the Node.js version manager.

Several Node.js version managers are accessible in the open-source server environment, including NVM, N, fnm, asdf, and Volta.

In this tutorial, we use the Fnm Node.js version manager, which is faster, simpler, and easier to use than other Node version managers. Fnm works with .node-version and .nvmrc files.

--

--

Rajdeep Singh
Rajdeep Singh

Written by Rajdeep Singh

Follow me if you learn more about JavaScript | TypeScript | React.js | Next.js | Linux | NixOS | Frontend Developer | https://linktr.ee/officialrajdeepsingh

Responses (2)