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

task.mdevals/scenario-8/

Cross-Platform Node.js Environment Setup Tool

Build a Python command-line tool that creates isolated Node.js environments on different platforms and architectures. The tool should automatically detect the system's platform and create an appropriate Node.js environment.

Requirements

Platform Detection

Detect the current operating system and processor architecture to determine the correct Node.js binaries to use.

Environment Creation

Create an isolated Node.js environment in a target directory with proper directory structure for the detected platform.

Activation Scripts

Generate shell activation scripts appropriate for the detected platform (bash for Unix-like systems, PowerShell for Windows).

Implementation

@generates

API

def setup_environment(target_dir: str, node_version: str = 'latest') -> None:
    """
    Create a Node.js virtual environment in the target directory.

    Args:
        target_dir: Directory path where the environment will be created
        node_version: Node.js version ('latest' or specific version like '20.0.0')

    Raises:
        RuntimeError: If environment creation fails
    """
    pass

Test Cases

  • Calling setup_environment('/tmp/nodeenv1', 'latest') creates a directory at /tmp/nodeenv1 @test
  • After calling setup_environment('/tmp/nodeenv2', 'latest'), the directory contains a bin/ subdirectory on Unix or Scripts/ on Windows @test
  • After calling setup_environment('/tmp/nodeenv3', '20.0.0'), running the node binary in the environment reports version 20.0.0 @test
  • After calling setup_environment('/tmp/nodeenv4', 'latest'), an activation script exists (activate or activate.ps1) in the appropriate directory @test

Dependencies { .dependencies }

nodeenv { .dependency }

Provides Node.js virtual environment creation and management capabilities with cross-platform support.

Install with Tessl CLI

npx tessl i tessl/pypi-nodeenv

tile.json