设置package.json的默认值

我想设置一些package.json属性的默认值。

例如,我在NPM上发表的大部分图书馆都有MIT许可证。 另外,我是他们大多数人的作者(有时候作者是我工作的公司)。

我怎样才能设置这样的默认值?

我期望以下行为:

 $ npm init ... author: (Ionică Bizău) license: (MIT) ... 

所以,只要按回车就可以设置默认值。

要查看npmconfiguration,请运行:

 npm config list 

这通常会包含这样的

 userconfig /home/scott/.npmrc 

猫上面的文件来查看所有覆盖

 npm config ls -l # to show all defaults 

您可以手动定义默认值

 npm config edit # view then change all settings 

或者您可以交互式设置默认值:

 npm set init.author.name "<Your Name>" npm set init.author.email "you@example.com" npm set init.author.url "example.com" npm set init.license = "MIT" 

每一套都有相应的get

使用npmrc来设置你的默认值。