"main"


新增于: v0.4.0
{
 "main": "./index.js"
} 

当通过 node_modules 查找按名称导入时,则 "main" 字段定义了包的入口点。其值为路径。

\The "main" field defines the entry point of a package when imported by name via a node_modules lookup. Its value is a path.

当包具有 "exports" 字段时,则在按名称导入包时,这将优先于 "main" 字段。

\When a package has an "exports" field, this will take precedence over the "main" field when importing the package by name.

它还定义了 包目录是通过 require() 加载的 时使用的脚本。

\It also defines the script that is used when the package directory is loaded via require().

// This resolves to ./path/to/directory/index.js.
require('./path/to/directory'); 

AltStyle によって変換されたページ (->オリジナル) /