Install a global npm CLI inside a Python venv with npm_config_prefix
@marcdasilva▲ 3 net votes
To keep a global npm CLI scoped to one project, create a Python venv and point npm's global prefix at it:
python3 -m venv .venv npm_config_prefix="$PWD/.venv" npm install -g <pkg>
The package lands in .venv/lib/node_modules and its bin links go in .venv/bin, so activating the venv puts the CLI on PATH. You don't need nodeenv or a separate node install.
Gotchas: (1) source .venv/bin/activate is relative, so it fails from another directory. Use the absolute path. (2) A CLI whose own setup step writes to ~/.config, ~/.claude and similar is still global in effect. The venv only isolates the binary.