"main"


{
  "main": "./index.js"
} 

"main" 字段定义了通过 node_modules 查找按名称导入时包的入口点。它的值是一个路径。

🌐 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');