CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-nodeenv

Node.js virtual environment builder for creating isolated Node.js environments

80

1.25x
Overview
Eval results
Files

environment.mddocs/

Environment Management

Core functionality for creating, configuring, and managing isolated Node.js virtual environments. Provides comprehensive environment setup with cross-platform shell integration and activation scripts.

Capabilities

Environment Creation

Creates a complete Node.js virtual environment with proper directory structure, activation scripts, and environment isolation.

def create_environment(env_dir, args):
    """
    Create a new Node.js virtual environment.
    
    Parameters:
    env_dir (str): Target directory for the environment
    args (argparse.Namespace): Parsed command-line arguments
    
    Creates directory structure, installs Node.js and npm if requested,
    sets up activation scripts for multiple shells, and configures
    the environment for isolated Node.js development.
    
    The created environment includes:
    - Node.js installation (version specified in args)
    - npm installation (if --with-npm specified)
    - Shell activation scripts (bash, zsh, fish, PowerShell, cmd)
    - Environment configuration and PATH management
    - Integration with Python virtualenv (if detected)
    """

Environment Directory Resolution

Determines the target directory for environment creation based on arguments and current context.

def get_env_dir(args):
    """
    Determine environment directory path from arguments.
    
    Parameters:
    args (argparse.Namespace): Parsed command-line arguments
    
    Returns:
    str: Absolute path to environment directory
    
    Handles various scenarios:
    - Explicit environment path specification
    - Default environment naming
    - Integration with existing Python virtualenv
    - Current working directory considerations
    """

Activation Script Installation

Installs shell activation and deactivation scripts for cross-platform environment management.

def install_activate(env_dir, args):
    """
    Install activation scripts for the Node.js environment.
    
    Parameters:
    env_dir (str): Environment directory path
    args (argparse.Namespace): Configuration arguments
    
    Creates activation scripts for multiple shells:
    - activate (bash/zsh)
    - activate.bat (Windows cmd)
    - activate.ps1 (PowerShell)
    - activate.fish (fish shell)
    
    Also creates corresponding deactivation functionality and
    configures environment variables for Node.js and npm.
    """

Pre-deactivation Hook

Sets up hooks that run before environment deactivation for cleanup operations.

def set_predeactivate_hook(env_dir):
    """
    Set up pre-deactivation hook for environment cleanup.
    
    Parameters:
    env_dir (str): Environment directory path
    
    Creates a hook script that runs before environment deactivation
    to perform necessary cleanup operations and restore the previous
    environment state properly.
    """

Usage Examples

Basic Environment Creation

import nodeenv
from argparse import Namespace

# Create environment with default settings
args = Namespace(
    node='latest',
    with_npm=True,
    jobs='2',
    without_ssl=False,
    source=False,
    requirements=None
)

nodeenv.create_environment('/path/to/myenv', args)

Environment with Custom Configuration

import nodeenv
from argparse import Namespace

# Create environment with specific Node.js version and build options
args = Namespace(
    node='16.20.0',
    with_npm=True,
    jobs='4',
    without_ssl=False,
    source=True,  # Build from source
    requirements='/path/to/requirements.txt',
    mirror='https://npm.taobao.org/mirrors/node'
)

nodeenv.create_environment('/path/to/custom-env', args)

Install with Tessl CLI

npx tessl i tessl/pypi-nodeenv

docs

cli.md

configuration.md

environment.md

index.md

node-install.md

package-management.md

utilities.md

version-management.md

tile.json