CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-nodeenv

tessl install tessl/pypi-nodeenv@1.9.0

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

Agent Success

Agent success rate when using this tile

80%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.25x

Baseline

Agent success rate without this tile

64%

task.mdevals/scenario-6/

Node.js Environment Builder with Custom NPM Configuration

Build a Python script that creates an isolated Node.js environment with specific NPM configuration requirements.

Requirements

Your script should create a Node.js virtual environment with the following capabilities:

  1. Environment Creation: Create a new virtual environment in a specified directory with Node.js installed.

  2. Custom NPM Version: Allow specifying a custom NPM version to install, independent of the version bundled with Node.js.

  3. Package Installation: Support installing packages from a requirements file containing package names and versions.

  4. Environment Update: Support updating packages in an existing environment without reinstalling Node.js.

The script should accept the following command-line arguments:

  • --env-dir (required): Directory path for the environment
  • --npm-version (optional): Specific NPM version to install (e.g., "9.8.1")
  • --requirements (optional): Path to a requirements file containing packages to install
  • --update-only (optional): Update packages without reinstalling Node.js

Test Cases

  • Creating an environment with a specific NPM version (e.g., "8.19.2") successfully installs that version rather than the bundled version @test
  • Installing packages from a requirements file successfully installs all listed packages @test
  • Using the update-only flag updates packages without reinstalling Node.js @test

Implementation

@generates

API

import argparse

def create_environment_with_npm(env_dir, npm_version=None, requirements_file=None, update_only=False):
    """
    Create or update a Node.js virtual environment with custom NPM configuration.

    Args:
        env_dir (str): Directory path for the environment
        npm_version (str, optional): Specific NPM version to install
        requirements_file (str, optional): Path to requirements file with packages
        update_only (bool): If True, only update packages without reinstalling Node.js

    Returns:
        bool: True if successful, False otherwise
    """
    pass

def main():
    """Command-line interface for the environment builder."""
    parser = argparse.ArgumentParser(description='Build Node.js environment with NPM configuration')
    parser.add_argument('--env-dir', required=True, help='Directory for the environment')
    parser.add_argument('--npm-version', help='Specific NPM version to install')
    parser.add_argument('--requirements', help='Path to requirements file')
    parser.add_argument('--update-only', action='store_true', help='Update packages only')

    args = parser.parse_args()

    success = create_environment_with_npm(
        args.env_dir,
        args.npm_version,
        args.requirements,
        args.update_only
    )

    return 0 if success else 1

if __name__ == '__main__':
    exit(main())

Dependencies { .dependencies }

nodeenv { .dependency }

Provides Node.js virtual environment management capabilities including NPM installation and package management.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/nodeenv@1.9.x
tile.json