Home > @rushstack/node-core-library > INodePackageJson
INodePackageJson interface
An interface for accessing common fields from a package.json file whose version field may be missing.
Signature:
export interface INodePackageJson
Remarks
This interface is the same as IPackageJson, except that the version field is optional. According to the NPM documentation and CommonJS Packages specification, the version field is normally a required field for package.json files.
However, NodeJS relaxes this requirement for its require() API. The "Folders as Modules" section from the NodeJS documentation gives an example of a package.json file that has only the name and main fields. NodeJS does not consider the version field during resolution, so it can be omitted. Some libraries do this.
Use the INodePackageJson interface when loading such files. Use IPackageJson for package.json files that are installed from an NPM registry, or are otherwise known to have a version field.
Properties
Property | Modifiers | Type | Description |
|---|---|---|---|
string | Record<string, string> | (Optional) The main entry point for the package. | ||
(Optional) An array of dependencies that must always be installed for this package. | |||
(Optional) An array of metadata for dependencies declared inside dependencies, optionalDependencies, and devDependencies. https://pnpm.io/package\_json\#dependenciesmeta | |||
string | (Optional) A brief description of the package. | ||
(Optional) An array of dependencies that must only be installed for developers who will build this package. | |||
string | string[] | Record<string, null | string | IPackageJsonExports> | (Optional) The "exports" field is used to specify the entry points for a package. See Node.js documentation | ||
string[] | (Optional) The "files" field is an array of file globs that should be included in the package during publishing. See the NPM documentation. | ||
string | (Optional) The URL to the project's web page. | ||
string | (Optional) The name of the license. | ||
string | (Optional) The path to the module file that will act as the main entry point. | ||
string | The name of the package. | ||
(Optional) An array of optional dependencies that may be installed for this package. | |||
(Optional) An array of dependencies that must be installed by a consumer of this package, but which will not be automatically installed by this package. | |||
(Optional) An array of metadata about peer dependencies. | |||
boolean | (Optional) Indicates whether this package is allowed to be published or not. | ||
string | IPackageJsonRepository | (Optional) The URL of the project's repository. | ||
Record<string, string> | (Optional) A table of package version resolutions. This feature is only implemented by the Yarn package manager. | ||
(Optional) A table of script hooks that a package manager or build tool may invoke. | |||
string | (BETA) (Optional) The path to the TSDoc metadata file. This is still being standardized: https://github.com/microsoft/tsdoc/issues/7\#issuecomment-442271815 | ||
string | (Optional) The path to the TypeScript *.d.ts file describing the module file that will act as the main entry point. | ||
Record<string, Record<string, [string, ...string[]]>> | (Optional) A table of TypeScript *.d.ts file paths that are compatible with specific TypeScript version selectors. This data take a form similar to that of the INodePackageJson.exports field, with fallbacks listed in order in the value array for example: or See the TypeScript documentation for details. | ||
string | (Optional) Alias for | ||
string | (Optional) A version number conforming to the Semantic Versioning (SemVer) standard. |