A wrapper for npm that stores node_modules outside of project and provides easy access to them.
Project description
npmenv
A wrapper for npm that stores node_modules outside of project and provides easy access to them.
npmenv is a Python module inspired by pipenv in that it stores packages outside of projects (in an OS-specific dir) to avoid cluttering projects. It also has a run command that puts node_modules/.bin in PATH before running the given command. If you install node in a project then it will have the added benefit of using that node version to run your code and third-party scripts. You can then lock down your node version per-project and upgrade them individually when desired.
Install: pip install npmenv
Supports: All platforms (Linux, MacOS, Windows)
Requires: Python 3.6+
How it works
Aside from env-... commands, npmenv hands over to npm. But before handing over, it symlinks your package.json and/or package-lock.json into the virtual environment and runs npm in that environment. You can access any node_modules files via the path returned by npmenv env-location, which will stay the same even if the environment is removed and recreated (though not if your project path changes).
Note: npmenv does not handle any other files generated by npm (such as shrinkwrap), though more features may be added in future.
CLI usage
npmenv 0.2.0
env-list List all currently existing environments
env-location Output path to env for current dir (may not exist yet)
env-modules [name] List items in node_modules (recursive if package name given)
env-run cmd [args] Run command with env's bin dir in start of PATH
env-rm [env_id] Remove the env for current dir (or env with given id)
env-cleanup Remove envs for projects that no longer exist
*any npm command*
Module API
class NpmenvException(builtins.Exception)
Exception for npmenv-related issues
env_cleanup() -> List[Tuple[str, pathlib.Path, str]]
Remove envs for projects that no longer exist (no package or lock file)
env_list() -> List[Tuple[str, pathlib.Path, Union[str, NoneType]]]
Return list of tuples (env id, project dir, issue with project existance)
env_location(proj_dir:Union[pathlib.Path, str]=None) -> pathlib.Path
Return env dir path for given project dir (may/may not exist yet)
env_npm(args:str='', proj_dir:Union[pathlib.Path, str]=None) -> subprocess.CompletedProcess
Execute npm with given args in env dir of given project dir
env_rm(identifier:Union[pathlib.Path, str]=None) -> pathlib.Path
Remove the env for given project dir or env id (defaults to CWD)
env_run(args:str, proj_dir:Union[pathlib.Path, str]=None, run_kwargs:Any={}) -> subprocess.CompletedProcess
Run a command with node_modules/.bin at start of PATH environment variable
Version history
0.2.0 Added run_kwargs arg to env_run
0.1.2 Added env-modules command
0.0.2 Improved typing support (no functional changes)
0.0.1 Improved documentation (no functional changes)
0.0.0 Version 0.0.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file npmenv-0.2.0.tar.gz.
File metadata
- Download URL: npmenv-0.2.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2276ae773943131beea626669bb5fe32d4a7dda280ff5a0adb1d97d80cfccb4e
|
|
| MD5 |
633932319e3be15da26d913673c3a2ee
|
|
| BLAKE2b-256 |
f0c83168bbad4fc3d567cbe530adafa82c3afcd637721543c1c7726ab19a8a0b
|
File details
Details for the file npmenv-0.2.0-py3-none-any.whl.
File metadata
- Download URL: npmenv-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83392ce10d0eb8d34e49aa76149db810784a042891f875b5a0b58e145de9bcf7
|
|
| MD5 |
f437aa42c4851a8fff5e55a9b348cbd0
|
|
| BLAKE2b-256 |
b9e3e2a6350f988773728ceab8797940a312e14dc69c4cad9921fe61d4cd1d71
|