设置package.json默认值

Ion*_*zău 3 json package node.js npm

我想设置几个package.json属性默认值.

例如,我在NPM上发布的大多数图书馆都有MIT许可证.此外,我是他们中的大多数人的作者(有时作者是我工作的公司).

如何设置此类默认值?

我期待以下行为:

$ npm init
...
author: (Ionic? Biz?u)
license: (MIT)
...
Run Code Online (Sandbox Code Playgroud)

因此,只需按Enter键即可设置默认值.

Sco*_*and 8

要查看npm配置,请运行:

npm config list
Run Code Online (Sandbox Code Playgroud)

通常会包含这样的

userconfig /home/scott/.npmrc
Run Code Online (Sandbox Code Playgroud)

在文件上面的猫看到你所有的覆盖

npm config ls -l #  to show all defaults
Run Code Online (Sandbox Code Playgroud)

您可以手动定义默认值

npm config edit  # view then change all settings
Run Code Online (Sandbox Code Playgroud)

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

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"
Run Code Online (Sandbox Code Playgroud)

每组都有相应的get