Skip to main content

Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser.

Project description

Node.js PyPI distribution

Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser.

The nodejs-bin Python package redistributes Node.js so that it can be used as a dependency of Python projects. With nodejs-bin you can call nodejs, npm and npx from both the command line and a Python API.

Note: this is an unofficial Node.js distribution.

This is intended for use within Python virtual environments and containers, it should probably not be used for global instillation.

This PyPI distribution is provided by https://github.com/samwillis/nodejs-pypi.

Install

To install:

pip install nodejs-bin

By default the command line node, npm and npx commands are not installed to prevent collisions with already installed Node.js versions. To install them:

pip install 'nodejs-bin[cmd]'

You can specify the Node.js version to install with:

pip install nodejs-bin==<version>

# Example:
pip install nodejs-bin==16.15.1

Command Line Usage

To run Node.js from the command line, use:

python -m nodejs

npm and npx are also available as nodejs.npm and nodejs.npx:

python -m nodejs.npm
python -m nodejs.npx

If you installed the optional command line commands with pip install 'nodejs-bin[cmd]' (see above), you can use them directly from the command line as you would normally with Node.js:

node
npm
npx

Python API Usage

node-bin has a simple Python API that wraps the Node.js command line with the Python subprocess.

For node, npm and npx there are .call(), .run() and .Popen() methods that match the equivalent subprocess methods.

To run Node.js from a Python program and return the exit code:

from nodejs import node, npm, npx

# Run Node.js and return the exit code.
node.call(['script.js', 'arg1', ...], **kwargs)

# Run npm and return the exit code.
npm.call(['command', 'arg1', ...], **kwargs)

# Run npx and return the exit code.
npx.call(['command', 'arg1', ...], **kwargs)

The call(args, **kwargs) functions wrap subprocess.call(), passes though all kwargs and returns the exit code of the process.

To run Node.js from a Python program and return a CompletedProcess object:

from nodejs import node, npm, npx

# Run Node.js and return the exit code.
node.run(['script.js', 'arg1', ...], **kwargs)

# Run npm and return the exit code.
npm.run(['command', 'arg1', ...], **kwargs)

# Run npx and return the exit code.
npx.run(['command', 'arg1', ...], **kwargs)

The run(args, **kwargs) functions wrap subprocess.run(), passes though all kwargs and returns a CompletedProcess.

Additionally, to start a Node.js process and return a subprocess.Popen object, you can use the Popen(args, **kwargs) functions:

from nodejs import node, npm, npx

# Start Node.js and return the Popen object.
node_process = node.Popen(['script.js', 'arg1', ...], **kwargs)

# Start npm and return the Popen object.
npm_process = npm.Popen(['command', 'arg1', ...], **kwargs)

# Start npx and return the Popen object.
npx_process = npx.Popen(['command', 'arg1', ...], **kwargs)

The Popen(args, **kwargs) functions wrap subprocess.Popen(), passes though all kwargs and returns a Popen object.

The nodejs.node api is also available as nodejs.run and nodejs.call and nodejs.Popen.

Finally, there are a number of convenient attributes on the nodejs module:

  • nodejs.node_version: the version of Node.js that is installed.
  • nodejs.path: the path to the Node.js executable.

Versions

nodejs-bin offers Node.js Current and LTS (long-term support) versions. See the Node.js Documentation for more information.

The full list of versions is available on PyPI is here: https://pypi.org/project/nodejs-bin/#history

License

The Node.js license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

nodejs_bin-16.15.1a2-py3-none-win_amd64.whl (27.6 MB view details)

Uploaded Python 3Windows x86-64

nodejs_bin-16.15.1a2-py3-none-win32.whl (25.9 MB view details)

Uploaded Python 3Windows x86

nodejs_bin-16.15.1a2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (31.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

nodejs_bin-16.15.1a2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (34.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

nodejs_bin-16.15.1a2-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (34.5 MB view details)

Uploaded Python 3manylinux: glibc 2.12+ x86-64

nodejs_bin-16.15.1a2-py3-none-macosx_11_0_arm64.whl (30.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

nodejs_bin-16.15.1a2-py3-none-macosx_10_9_x86_64.whl (32.2 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file nodejs_bin-16.15.1a2-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for nodejs_bin-16.15.1a2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 6e3628c7ef2cf0d75aa234aa32312de070556b9eb126691c361ca15c834404c6
MD5 4b2ad310eedcf496083a62ccb43038ba
BLAKE2b-256 4613b0d508da5a46075c487b7c39bb415d002294c0f6173f7d06f5563becea1e

See more details on using hashes here.

File details

Details for the file nodejs_bin-16.15.1a2-py3-none-win32.whl.

File metadata

  • Download URL: nodejs_bin-16.15.1a2-py3-none-win32.whl
  • Upload date:
  • Size: 25.9 MB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.6

File hashes

Hashes for nodejs_bin-16.15.1a2-py3-none-win32.whl
Algorithm Hash digest
SHA256 7e8421afb8fb81bd70331d4f47640d9a6c052ad5586cf9cc2a551b4fca4ba541
MD5 b2743c4799358eb229f7a9d8e156f6cb
BLAKE2b-256 438306e7c176372e37b55a639b4cd98c0f10bc778e06b6c953e43b0c97f9a6f2

See more details on using hashes here.

File details

Details for the file nodejs_bin-16.15.1a2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for nodejs_bin-16.15.1a2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 f1c9fbb8e4147e16ee6a2708fb1c86452ad4bdf00939e7a89ca35c75fa6346a3
MD5 4bf176b2b99557e00040d21c58ec573e
BLAKE2b-256 6b97a5936104d165c683b014438946fd65fd7165ce63eefad69c0e5ee170a538

See more details on using hashes here.

File details

Details for the file nodejs_bin-16.15.1a2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for nodejs_bin-16.15.1a2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 121548fcfbadb7f27bd30581f6d0009368a5b21212da67c20f9ed687c563e155
MD5 7f81357039fb1d560466d79244de8f96
BLAKE2b-256 55a4221c21074dd422571d03ebc65d8e57363c7c80c82ea5cbc63f7c1297ea21

See more details on using hashes here.

File details

Details for the file nodejs_bin-16.15.1a2-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for nodejs_bin-16.15.1a2-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 8e7429cf8b639ca05b2f44467c413bfca97f72fa42ec92622067e1b642d79867
MD5 3594eeb469c78e84213f875b600b3f40
BLAKE2b-256 caf78798c5e4942023e8c10ade47c290ecf8e725f5b12af7923b3b1a3276d3b3

See more details on using hashes here.

File details

Details for the file nodejs_bin-16.15.1a2-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nodejs_bin-16.15.1a2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bdf290da0127a54775308304371117aac8735e48b017491fbc3d2bed3c760af1
MD5 f9a5252dc06bcf32e2ca9d933b38e2d5
BLAKE2b-256 d43f886fde55ee258b6f8ae4a20c0a5a987a1078fdda734c97e3972e53970264

See more details on using hashes here.

File details

Details for the file nodejs_bin-16.15.1a2-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for nodejs_bin-16.15.1a2-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c19056f3ab317c429717f4311159d2fa44b27545f0fd204e6ff69b872ebab9f4
MD5 a87ffcd28744fd8e906ab8e0cd75850c
BLAKE2b-256 25087ca26c408b4e2b2338f15f0ba6dd5f8e9f498ae1227da36bb098d37de9b3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page