Skip to content

NVML is a lightweight and efficient solution for managing Node.js versions on Linux systems. Whether you're a sysadmin responsible for server-wide Node.js installations or a developer seeking a hassle-free version management tool, NVML simplifies the process.

License

Watchdog0x/nvm-light

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node Version Manager Light (NVML)

Static Badge

This script is tailored for sysadmins and server environments where managing Node.js versions at the system level is crucial. Unlike user-based NVM installations that are common for development environments, system-based NVM ensures consistent Node.js versions across all users and applications on the server.

Features:

  • Install Node.js Versions: Download and install specific Node.js versions from the official Node.js release repository.

  • List Installed Versions: Display a list of Node.js versions installed on your system, indicating the currently active version.

  • Set Active Version: Set the active Node.js version, creating symbolic links for node, npx, and npm.

  • Remove Installed Version: Safely remove an installed Node.js version, excluding the currently active version.

  • Patch Updates: Check for and install updates to existing Node.js versions, with an option to clean up old versions.

Installation

1) Remove the system Node.js and let NVML manage it:

sudo apt purge --auto-remove nodejs

2) Navigate to your preferred directory:

# in my case I will use opt
cd /opt

3) Clone the repository to your server:

sudo git clone https://github.com/Watchdog0x/nvm-light.git && cd nvm-light

4) Create a symbolic link to the completion script:

sudo ln -rfs nvml_completion /etc/bash_completion.d/

Note

The nvml_completion script provides command-line completion for nvml commands, helping you discover available versions and options. After linking, you can use tab completion to explore the available Node.js versions and subcommands.

5) Create a symbolic link to the nvml:

sudo ln -rfs nvml /usr/local/bin/

6) Don't Forget to Source Your Bashrc:

source ~/.bashrc

7) Don't forget to install the preferred Node.js version:

sudo nvml -i 20.9.0 -s 20.9.0 -l

Output

Node.js version 20.9.0  downloaded successfully to /opt/nvm-light/nodejs
Node.js version 20.9.0  extracted successfully
Node.js version 20.9.0  has been set successfully.
Available Node.js versions installed on your system:
* Node.js 20.9.0  (Running)

Note

Use -i to install, -s to set the Node.js version, and -l to list them for checking.

Important

The global installation path for npm packages (npm install -g) is controlled by the system administrator. The standard prefix is set to /usr/local. Ensure that users have the necessary permissions to install global packages or consider running npm commands with elevated privileges.

Usage:

nvml [OPTIONS]
  • -i, --install: Install a specific Node.js version.
  • -l, --list: List available Node.js versions on your system.
  • -s, --set: Set the active Node.js version.
  • -r, --remove: Remove an installed Node.js version.
  • -p, --patch: Update all installed Node.js versions to the latest. Subcommand clean removes old versions.
  • -v, --version: Print the version of nvml
  • -h, --help: Display the help message.

Set up Cron Job for Auto-Updates

1) Open the crontab editor:

sudo crontab -e

2) Add a cron job to automatically update Node.js versions daily At 00:00:

# Example: Run nvml patch (update) daily at midnight and log the output
**0 0 * * * /path/to/nvm-script/nvml -p >> /var/log/nvml-update.log 2>&1

Note

When using sudo crontab -e to edit the crontab for the root user, you can also add the clean option to enable automatic cleanup. Ensure you have the necessary permissions and use this command responsibly.

Contributing

Contributions are welcome! Feel free to open issues, submit pull requests, or provide suggestions. Please follow the Contributing Guidelines.

License

This project is licensed under the MIT License

About

NVML is a lightweight and efficient solution for managing Node.js versions on Linux systems. Whether you're a sysadmin responsible for server-wide Node.js installations or a developer seeking a hassle-free version management tool, NVML simplifies the process.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages