Coder Social home page Coder Social logo

watchdog0x / nvm-light Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 23 KB

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: MIT License

Shell 100.00%
bash node nodejs nodejs-server nvm nvm-light nvml sysadmin version-manager auto-update

nvm-light's Introduction

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

nvm-light's People

Contributors

watchdog0x avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.