Skip to content

Commit 18b296e

Browse files
committed
Update readme
1 parent 5714a15 commit 18b296e

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

README.pypi.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Node.js PyPI distribution
55

66
The [node-js][pypi] Python package redistributes Node.js so that it can be used as a dependency of Python projects.
77

8+
**This is intended for use within Python virtual environments and containers, it should not be used for global instillation.**
9+
810
[zig]: https://nodejs.org/
911
[pypi]: https://pypi.org/project/node-js/
1012

@@ -17,14 +19,33 @@ To run the Zig toolchain from the command line, use:
1719
python -m nodejs
1820
```
1921

20-
To run Node.js from a Python program, use `sys.executable` to locate the Python binary to invoke. For example:
22+
`npm` and `npx` are also available as `python -m nodejs.npm` and `python -m nodejs.npx`.
23+
24+
To run Node.js from a Python program:
25+
26+
```python
27+
from nodejs import node, npm, npm
28+
29+
# Run Node.js and return the exit code.
30+
node.run(['script.js', 'arg1', ...])
31+
32+
# Run npm and return the exit code.
33+
npm.run(['command', 'arg1', ...])
34+
35+
# Run npx and return the exit code.
36+
npx.run(['command', 'arg1', ...])
37+
```
38+
39+
Alternatively use `sys.executable` to locate the Python binary to invoke. For example:
2140

2241
```python
2342
import sys, subprocess
2443

2544
subprocess.call([sys.executable, "-m", "nodejs"])
2645
```
2746

47+
`node`, `npm` and `npx` are also added to your Python environment's `bin` directory. This is usually on your `PATH` and so they should be available in your shell environment.
48+
2849
License
2950
-------
3051

0 commit comments

Comments
 (0)