Registry / devops / pynpm
library0.3.0pypypi✓ verified 88d ago

A Python interface to NPM and package.json, providing utilities to run npm scripts and manage Node.js dependencies from Python. Version 0.3.0 is the latest, with infrequent releases.

pip install pynpm
INSTALL
IMPORT
SIG · PYNPM
P
pynpm
devopspythonv0.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NPMPackage
✓ from pynpm import NPMPackage
✗ from pynpm.package import NPMPackage
Prior to 0.2.0, the class was in pynpm.package.
pnpm
✓ from pynpm import pnpm
✗ from pynpm import pnpm as npm
pnpm is a separate function, not an alias for npm.

Create an NPMPackage instance pointing to a directory with package.json, then run an npm script.

from pynpm import NPMPackage pkg = NPMPackage('/path/to/project') pkg.run_script('build')
Debug
Known issues
breakingNPMPackage now requires a path argument; previously it defaulted to the current directory.
fix
Always pass a path to NPMPackage (e.g., NPMPackage('.')) for current directory.
affects: 0.2.0 and later
gotchapnpm() function is separate from npm; it executes pnpm not npm.
fix
Use pnpm() only if you have pnpm installed. For npm scripts, always use NPMPackage.
affects: All
deprecatedThe function pynpm.npm has been removed; use NPMPackage instead.
fix
Replace calls to pynpm.npm() with NPMPackage().run_script().
affects: 0.3.0
Errors
Common errors & fixes
AttributeError: module 'pynpm' has no attribute 'npm'
The pynpm.npm function was removed in 0.3.0.
fix
Use from pynpm import NPMPackage and NPMPackage(path).run_script('script_name').
FileNotFoundError: [Errno 2] No such file or directory: 'npm'
Node.js/npm is not installed or not in PATH.
fix
Install Node.js and npm, or ensure they are in your system PATH.
Upgrade
Version history
0.3.0latest on PyPI · released Feb 20, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
pynpm — pip install pynpm · libregistry