npm 配置命令的区别

Difference between npm configuration commands

npm config set <key> <value>

npm set <key> <value>

同义词?

使用这两个命令配置 npm init,将 init 配置添加到 /home/.npmrc

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

它们是同义词。

检查 GitHub 上的 NPM 源代码:set 命令的代码很短,调用了 configset

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 命令:https://github.com/npm/npm/blob/master/lib/config.js