It is possible to set the global npm config via the global switch

# short version
npm config set init-version "0.0.1" -g

# long version
npm config set init-version "0.0.1" --global

The location of the global npm config in nvm is tied to node version, rendering it unsuitable for dotfiles

$ npm config get prefix

The actual file location is thus {prefix}/etc/npmrc^[]


When installing new node version with nvm, the config file has to be copied over

nvm install 15.4
cp ~/.nvm/versions/node/v14.9.0/etc/npmrc ~/.nvm/versions/node/v15.4.0/etc/npmrc

Not using global setup

Here's how I store npm config among the dotfiles, using so called userconfig instead of a global config

  • Install nvm
sudo pacman -S nvm
nvm install stable
  • Configure the init values
npm config set init-version "0.0.1"
npm config set init-author-email ""
npm config set init-author-name "Peter Babič"
npm config set init-license "MIT"
npm config set init-author-url ""

Alternatively, paste the values into ~/.npmrc manually

init-author-name=Peter Babič
  • Store the file among your dotfiles, i.e. via yadm
yadm add ~/.npmrc && yadm commit
  • Initialize the project prompting the values
npm init -y

Produces the pre-configured package.json file straight away, saving time

  "name": "project",
  "version": "0.0.1",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  "keywords": [],
  "author": "Peter Babič <> (",
  "license": "MIT"

Used versions for the completeness

$ nvm --version

$ npm --version

$ node --version

$ yay -Qi yadm | grep Version
Version         : 2.5.0-1