Node.js package.json 字段定义
¥Node.js package.json
field definitions
本节描述了 Node.js 运行时使用的字段。其他工具(例如 npm)使用其他字段,这些字段被 Node.js 忽略且未在此处记录。
¥This section describes the fields used by the Node.js runtime. Other tools (such as npm) use additional fields which are ignored by Node.js and not documented here.
package.json
文件中的以下字段在 Node.js 中使用:
¥The following fields in package.json
files are used in Node.js:
-
"name"
- 在包中使用命名导入时相关。也被包管理器用作包的名称。¥
"name"
- Relevant when using named imports within a package. Also used by package managers as the name of the package. -
"main"
- 加载包时的默认模块,如果没有指定 exports,在引入 exports 之前的 Node.js 版本中。¥
"main"
- The default module when loading the package, if exports is not specified, and in versions of Node.js prior to the introduction of exports. -
"type"
- 决定是否将.js
文件加载为 CommonJS 或 ES 模块的包类型。¥
"type"
- The package type determining whether to load.js
files as CommonJS or ES modules. -
"exports"
- 包导出和条件导出。当存在时,限制可以从包中加载哪些子模块。¥
"exports"
- Package exports and conditional exports. When present, limits which submodules can be loaded from within the package. -
"imports"
- 包导入,供包本身内的模块使用。¥
"imports"
- Package imports, for use by modules within the package itself.