Nodeenv is a Python tool that facilitates creating isolated Node.js environments, similar to how `virtualenv` manages Python environments. It allows developers to install specific Node.js versions and global npm packages within a dedicated directory, preventing conflicts between different projects. Currently at version 1.10.0, the library maintains an active development pace with several releases per year, incorporating new Python and Node.js version support, as well as bug fixes and improvements like UV virtual environment integration.
pip install nodeenvNo compatibility data collected yet for this library.
Nodeenv is primarily a command-line tool. The standard workflow involves setting up a Python virtual environment, installing `nodeenv` into it, and then using `nodeenv` to create a Node.js environment. The `--python-virtualenv` (or `-p`) flag integrates the Node.js environment directly into the currently active Python virtual environment, updating its activation scripts. After installation, reactivating the Python environment or sourcing the `node_env/bin/activate` script ensures the new Node.js environment is active.
Upgrade Python to 3.7+ or constrain `nodeenv` version to `<1.7.0` (e.g., `pip install nodeenv<1.7.0`).
Always `source /path/to/your_venv/bin/activate` before running `nodeenv -p`.
Avoid `--ignore_ssl_certs` unless absolutely necessary and ensure you understand the security implications. Prefer setting up proper SSL certificates or using a trusted mirror if network issues persist.
Use the `--verbose` flag for detailed output or the `--prebuilt` flag to prefer pre-compiled Node.js binaries for faster installation (`nodeenv --prebuilt`).
Execute shell commands directly in a shell (e.g., terminal or `.sh` script). If a shell command must be run from within a Python script, use Python's `subprocess` module (e.g., `subprocess.run(['python', '-m', 'venv', 'my_node_project'], check=True)`).
To execute shell commands from within a Python script, use the `subprocess` module (e.g., `import subprocess; subprocess.run(['python', '-m', 'venv', 'my_node_project'], check=True)`) or `os.system()` (e.g., `import os; os.system('python -m venv my_node_project')`).Ensure Python's script directory (e.g., `C:\PythonXX\Scripts` or `C:\Users\YourUser\AppData\Roaming\Python\PythonXX\Scripts`) is added to your system's PATH environment variable, then restart your terminal or IDE.
Add the directory where `pip` installs scripts (e.g., `export PATH=$PATH:~/.local/bin` for Linux/macOS or the equivalent for your Python installation) to your shell's configuration file (e.g., `~/.bashrc`, `~/.zshrc`) and then `source` it or open a new terminal.
Activate your `nodeenv` environment using `source /path/to/your/env/bin/activate`. If the issue persists, try recreating the environment with a specific Node.js version using `nodeenv my_env --node=lts`.
If behind a proxy, set `http_proxy` and `https_proxy` environment variables. For SSL certificate issues, try using the `--ignore-ssl-certs` flag when creating the environment: `nodeenv my_env --ignore-ssl-certs`.
First, activate your Python virtual environment (e.g., `source /path/to/my/python_venv/bin/activate`), then run `nodeenv -p` to install Node.js into it.