Skip to main content

py-node-manager

A tool library for conveniently using Node.js in Python.

Tests Coverage GitHub PyPI Ruff

English | 简体中文

Installation

pip install py-node-manager

Usage

Basic Usage

from py_node_manager import NodeManager

# Create NodeManager instance
# download_node=True means automatically download Node.js if not found in system
# node_version specifies the Node.js version to download
manager = NodeManager(download_node=True, node_version='18.17.0')

# Get paths to Node.js, npm, and npx
node_path = manager.node_path  # Path to downloaded Node.js, None if using system Node.js
npm_path = manager.npm_path    # Path to npm
npx_path = manager.npx_path    # Path to npx

# Get environment variables (if using downloaded Node.js)
node_env = manager.node_env    # Environment variables dictionary

Running Node.js Commands

import subprocess
from py_node_manager import NodeManager

manager = NodeManager(download_node=True, node_version='18.17.0')

# Run Node.js commands
result = subprocess.run(
    [manager.npm_path, 'init', '-y'],
    env=manager.node_env,
    capture_output=True,
    text=True
)
print(result.stdout)

Without Automatic Node.js Download

from py_node_manager import NodeManager

# Will raise an exception if Node.js is not found in the system
manager = NodeManager(download_node=False, node_version='18.17.0')

Testing

This project uses pytest for testing with 100% code coverage.

Running Tests

To run the tests in the conda environment:

# Install dependencies
pip install -e .
pip install -r requirements-dev.txt

# Run tests
pytest tests/ -v

# Run tests with coverage report
pytest tests/ --cov=py_node_manager --cov-report=term-missing

Test Structure

  • tests/test_node_manager.py - Complete test suite for NodeManager class
  • tests/conftest.py - pytest configuration
  • tests/__init__.py - Package initialization

All code paths are tested including:

  • Normal execution paths
  • Error handling scenarios
  • Platform-specific behaviors
  • CLI mode logging
  • Cached Node.js usage

Metadata

Release files for py-node-manager 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-node-manager 0.1.2
File Size Uploaded
py_node_manager-0.1.2.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-node-manager 0.1.2
File Interpreter ABI Platform
py_node_manager-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / py_node_manager-0.1.2.tar.gz

Download URL py_node_manager-0.1.2.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b61823e262f0bcc0de9bb1c0454e1ec5a0db807e953515fff64b1d5d96310dc2
BLAKE2b-256 checksum
How to use checksums
316a824783948be8f05fbc3a0ad2fceaefb986fef2e30f1d650cd360a2aaceb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Release files / py_node_manager-0.1.2-py3-none-any.whl

Download URL py_node_manager-0.1.2-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
696876aa0cd4859d580638e8432abe8355029744075891bb9be4315e2ae25512
BLAKE2b-256 checksum
How to use checksums
3465f3322a61d80f8232a0ba40b76829aac295abd5684f1e999efa1aef3a4665
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page