Python interface to your NPM and package.json.
Further documentation is available on https://pynpm.readthedocs.io/.
Installation
PyNPM is on PyPI so all you need is:
$ pip install pynpm
Usage
First point PyNPM to your package.json:
from pynpm import NPMPackage
pkg = NPMPackage('path/to/package.json')
Now you can run e.g. npm install from within Python:
pkg.install()
Arguments are also support so you can run e.g. npm run build --report:
pkg.run_script('build', '--report')
Want to use yarn instead?
from pynpm import YarnPackage
pkg = YarnPackage('path/to/package.json')
pkg.install()
By default NPM output is piped through and the function call will wait for NPM to finish. If you want to silence the output or interact with process pass wait=False and you will get a subprocess.POpen object back:
p = pkg.install(wait=False)
p.wait()
By default you can run the following NPM commands:
build
init
install
link
run-script
start
stop
test
You can also run other NPM commands or restrict which commands you can run:
pkg = NPMPackage('path/to/package.json', commands=['install'])
Trouble shooting
Windows user may face the following error when running the NPM command:
[WinError 2] The system cannot find the file specified
It means supbrossess is unable to run the specific command. To fix this issue, use the shell=True option uppon class initialization:
pkg = NPMPackage('path/to/package.json', shell=True)
Release files for pynpm 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pynpm-0.3.2.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pynpm-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.6 kB
Release files / pynpm-0.3.2.tar.gz
| Download URL | pynpm-0.3.2.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bce2121af57c257d68d70b57e72ec9e67d07f01cb9605751e45c972ae6e8ac7f
|
|
BLAKE2b-256 checksum How to use checksums |
493ebe0f6546cbeb84d9566c749faae3f1092d36261aaa918b9ddf3155a412b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pynpm-0.3.2-py3-none-any.whl
| Download URL | pynpm-0.3.2-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1ed2f0df2be17c1f4beb0ecf459bfa1148a4719d5d2a55d757d4bb09a875a191
|
|
BLAKE2b-256 checksum How to use checksums |
26fa1fb7f67a31c5fbaaed59523ba22b4bc514fb326985fdb3c050d7c4e997c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|