Node.js virtual environment builder for creating isolated Node.js environments
npx @tessl/cli install tessl/pypi-nodeenv@1.9.0A comprehensive tool for creating isolated Node.js environments, similar to Python's virtualenv. nodeenv enables developers to install and manage multiple Node.js versions in separate environments without conflicts, supports integration with existing Python virtual environments, and offers extensive configuration options for different Node.js versions, npm versions, SSL settings, and compilation parameters.
pip install nodeenvimport nodeenvFor programmatic access to specific functions:
from nodeenv import main, Config, create_environment, get_node_versionsCreate a new Node.js environment:
nodeenv myenvActivate the environment:
source myenv/bin/activateDeactivate the environment:
deactivate_nodeimport nodeenv
import sys
# Parse command line arguments and create environment
sys.argv = ['nodeenv', '--node=16.20.0', 'my_node_env']
nodeenv.main()nodeenv follows a modular design with distinct functional areas:
This design provides maximum flexibility for development workflows, allowing developers to test applications across different Node.js versions while maintaining clean separation between projects.
Main entry point for the nodeenv command-line tool, providing argument parsing, configuration loading, and orchestration of environment creation operations.
def main(): ...
def make_parser(): ...
def parse_args(check=True): ...
def create_logger(): ...Core functionality for creating, configuring, and managing isolated Node.js virtual environments with shell integration and activation scripts.
def create_environment(env_dir, args): ...
def get_env_dir(args): ...
def install_activate(env_dir, args): ...
def set_predeactivate_hook(env_dir): ...Node.js version management including downloading prebuilt binaries, building from source code, and copying installations with platform-specific optimizations.
def install_node(env_dir, src_dir, args): ...
def install_node_wrapped(env_dir, src_dir, args): ...
def copy_node_from_prebuilt(env_dir, src_dir, node_version): ...
def build_node_from_src(env_dir, src_dir, node_src_dir, args): ...npm installation and package management functionality including requirements file processing and package installation with version management.
def install_npm(env_dir, _src_dir, args): ...
def install_npm_win(env_dir, src_dir, args): ...
def install_packages(env_dir, args): ...Node.js version discovery, parsing, and selection including fetching available versions from remote repositories and determining latest stable and LTS releases.
def get_node_versions(): ...
def print_node_versions(): ...
def get_last_stable_node_version(): ...
def get_last_lts_node_version(): ...
def parse_version(version_str): ...Configuration system for managing default settings, loading configuration files, and handling environment-specific options.
class Config(object): ...Cross-platform utility functions for file operations, process execution, network requests, and system compatibility checks.
def mkdir(path): ...
def make_executable(filename): ...
def writefile(dest, content, overwrite=True, append=False): ...
def callit(cmd, show_stdout=True, in_shell=False, **kwargs): ...
def urlopen(url): ...
def copytree(src, dst, symlinks=False, ignore=None): ...class Config(object):
"""Configuration namespace with defaults and loading capabilities."""
node: str
npm: str
with_npm: bool
jobs: str
without_ssl: bool
debug: bool
profile: bool
make: str
prebuilt: bool
ignore_ssl_certs: bool
mirror: str
@classmethod
def _load(cls, configfiles, verbose=False): ...
@classmethod
def _dump(cls): ...nodeenv_version: str # Package version string
is_PY3: bool # Python 3 detection flag
is_WIN: bool # Windows platform detection flag
is_CYGWIN: bool # Cygwin platform detection flag
ignore_ssl_certs: bool # SSL certificate validation flag
src_base_url: str # Base URL for Node.js downloads