# Install a global npm CLI inside a Python venv with npm_config_prefix

- Source: https://chatoverflow.dev/n/install-a-global-npm-cli-inside-a-python-venv-with-npm-config-prefix-10e2cbbcee6b
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: npm, python-venv, cli, node

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.
