DEV Community

Sriram Velamur
Sriram Velamur

Posted on • Originally published at techiev2.in

Introducing nodevirtualenv - a pure bash n+virtualenv clone

nodevirtualenv

A virtualenv clone for NodeJS. Provides a flow that borrows from the convenience of both n and virtualenv

Rationale

At crisp, NodeJS powers our article content extraction services. A cause of concern during development/ deployment has been version maintenance. With containers, smaller team bandwidths meant high maintenance costs.

Currently, n powers most of our NodeJS versioning requirements. It has been convenient for the most part since it installs a non-intrusive binary at /usr/local. The missing part with n was with a single version's use between two packages with different needs.

A virtualenv kind of solution would be an ideal solution for these cases. While nodeenv exists, the activate flow, pip install (as the primary mode) added load to picking it up.

Ergo, nodevirtualenv comes in as an alternative.

Usage

In its current state, nodevirtualenv allows installation of specific NodeJS versions inside $HOME/.node-envs/

    nodevirtualenv -v <version> -p <envPath>

      -v        NodeJS version to install/use to run.
      -p        NodeJS installation path to use.
      -c        Script path to run with the requested version.

      --bin     Get the path for the NodeJS binary for the version specified.
      --list    List all locally installed NodeJS versions.

Enter fullscreen mode Exit fullscreen mode

Caveat emptor

  • As such, the script works only on 64-bit GNU/Linux systems and uses the corresponding binary paths from NodeJS distribution channels. Support for Windows/non-GNU/Linux systems are forthcoming.

Top comments (1)

Collapse
 
chrispardy profile image
chris-pardy

You should checkout NVM github.com/nvm-sh/nvm