Config File Locator

npm config file locations


Commands use a POSIX shell (macOS, Linux, or WSL). Install the named editor or CLI first. Before using an environment-variable path, check that the variable is set to a non-empty, intended path. When using vi or Notepad, ensure the parent directory exists and is writable. A missing file is created when you save it; Notepad may ask to create it.

This page shows npmrc file precedence: Project, User, Global, then Builtin. Command-line options override environment variables, and environment variables override npmrc files. Project .npmrc is not read in global mode, such as npm install -g. Paths are installation-dependent templates, not detected files.

  1. Project level

    Highest file priority

    Run commands from the project root (the directory containing package.json). Applies only to this project; not read in global mode (for example, npm install -g).

    Config file location
    <project>/.npmrc
    Commands
    vi .npmrc
  2. User level

    Second priority

    Applies to your user account.

    Config file location
    ~/.npmrc
    Commands
    vi ~/.npmrc
  3. Global level

    Third priority

    Applies to every user of this npm installation.

    Config file location
    $PREFIX/etc/npmrc
    Commands
    npm config edit --location=global
  4. Builtin level

    Lowest file priority

    Bundled with npm so distribution maintainers can provide default configuration. Normally not edited by users.

    Config file location
    <npm installation>/npmrc
    Replace <npm installation> with the directory containing npm itself, not the Node.js installation prefix. The exact path depends on how npm was installed.

Official npm documentation