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 installation.

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-14.19.3a3-py3-none-win_amd64.whl (30.6 MB view details)

Uploaded Python 3Windows x86-64

nodejs_bin-14.19.3a3-py3-none-win32.whl (28.9 MB view details)

Uploaded Python 3Windows x86

nodejs_bin-14.19.3a3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (34.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

nodejs_bin-14.19.3a3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (36.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

nodejs_bin-14.19.3a3-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (36.8 MB view details)

Uploaded Python 3manylinux: glibc 2.12+ x86-64

nodejs_bin-14.19.3a3-py3-none-macosx_10_9_x86_64.whl (34.9 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file nodejs_bin-14.19.3a3-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for nodejs_bin-14.19.3a3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 84a30897ed9c2efc766a2d571b285b43656c4fad8e7292dba626fd7e9e1cec4a
MD5 446f7246b37f027caa9fd83bb9a308c6
BLAKE2b-256 3cf2a2c440fe29136e260f0218112dd4b186426648c73a0b714c2c5b1b7dae43

See more details on using hashes here.

File details

Details for the file nodejs_bin-14.19.3a3-py3-none-win32.whl.

File metadata

  • Download URL: nodejs_bin-14.19.3a3-py3-none-win32.whl
  • Upload date:
  • Size: 28.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-14.19.3a3-py3-none-win32.whl
Algorithm Hash digest
SHA256 0236392250691065ce0e6add4a1e48a49bc5cc5b41edc9cc23bc8009745952e0
MD5 825340dbafc4567c7155a7a4b354393a
BLAKE2b-256 9edc22f6e660f7cecda1109c0d9586fbd61c651ba1e0ea565dcd54254e560631

See more details on using hashes here.

File details

Details for the file nodejs_bin-14.19.3a3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for nodejs_bin-14.19.3a3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 18f9c46eab601f75a2f37275e6c225f0807aaa52e9f71bc0f51f4f3b2cd30990
MD5 7e06595213fdb5b1d25f884e053081b1
BLAKE2b-256 0bd0fcd71d58e605ca4451ea72d59d7e71af1d22767e4c5bff3af2be81b197b4

See more details on using hashes here.

File details

Details for the file nodejs_bin-14.19.3a3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for nodejs_bin-14.19.3a3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f5dcbb29ed6c5f947373fb8b5a09cabcf0b70bb0ae54b6de771e492a02d5abb0
MD5 20fd6d2acbb0bbf3de7bd4dd2211aae3
BLAKE2b-256 28fc3f023aff643b0e417532624328a5b5110567e473a6c8e1f0e16f832fa4cf

See more details on using hashes here.

File details

Details for the file nodejs_bin-14.19.3a3-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for nodejs_bin-14.19.3a3-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 b2231641d813a40fe3473e04aae07e069cae140b0c2f0e2a96fd22cb8eedb0a6
MD5 829b10ae697dd60c3ab60261de249c56
BLAKE2b-256 5483c2ba31e8fb137f65b5da44d0a3eafb64ceffc5323e9cea459e65c541e326

See more details on using hashes here.

File details

Details for the file nodejs_bin-14.19.3a3-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for nodejs_bin-14.19.3a3-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 10198e2c3eb0a3669a19592b71680ab3a2c0cd56df7864802557d29bfd213be8
MD5 f8cbdabaa52530ac4d1326685ccf6c28
BLAKE2b-256 f8883d2f1e2b9ce6c3450eb33944ea8e54ac19081c8f4953be5efe2bc3700d14

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