npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Change or add a new config option to npm?

How do I add a new config option to the npm CLI?

  1. In lib/config/defaults.js, add the option to both the defaults and types objects in that file (they’re big and searchable and have configuration you can figure out based on surrounding options).

  2. If it makes sense, add a shorthand for your option in exports.shorthands in that file, as well. Generally, this should not be needed.

  3. Go to doc/misc/ and add the option, in alphabetical order, following the formatting for the other options.

  4. If the config option is meant to be a commonly-used flag for a specific command, go to doc/cli/<command>.md and add it to the synopsis and/or an “options” section, as you deem appropriate.

Note: for Boolean options, npm automatically handles a --no- prefix as making that option false. So --no-package-lock just makes the package-lock option be false.