tessl install tessl/pypi-nodeenv@1.9.0Node.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%
Build a Python script that creates an isolated Node.js environment with specific NPM configuration requirements.
Your script should create a Node.js virtual environment with the following capabilities:
Environment Creation: Create a new virtual environment in a specified directory with Node.js installed.
Custom NPM Version: Allow specifying a custom NPM version to install, independent of the version bundled with Node.js.
Package Installation: Support installing packages from a requirements file containing package names and versions.
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@generates
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())Provides Node.js virtual environment management capabilities including NPM installation and package management.