npmnpm-init

Difference between npm configuration commands


Are

npm config set <key> <value>

and

npm set <key> <value>

synonymous?

Configuration of npm init with both of this commands, add init configuration to /home/.npmrc

npm config set init.author.name 'Some One'
npm set init.author.email 'some@one.com

Solution

  • They are synonymous.

    Check NPM's source code on GitHub: The code of the set command is short and calls config's set.

    https://github.com/npm/npm/blob/master/lib/set.js

    module.exports = set
    
    set.usage = 'npm set <key> <value> (See `npm config`)'
    
    var npm = require('./npm.js')
    
    set.completion = npm.commands.config.completion
    
    function set (args, cb) {
      if (!args.length) return cb(set.usage)
      npm.commands.config(['set'].concat(args), cb)
    }
    

    config command: https://github.com/npm/npm/blob/master/lib/config.js