RoadmapShopEvents
Skip to main content

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

PropertyTypeDescription
bin?string(Optional) The main entry point for the package.
dependencies?IPackageJsonDependencyTable(Optional) An array of dependencies that must always be installed for this package.
description?string(Optional) A brief description of the package.
devDependencies?IPackageJsonDependencyTable(Optional) An array of dependencies that must only be installed for developers who will build this package.
homepage?string(Optional) The URL to the project's web page.
license?string(Optional) The name of the license.
main?string(Optional) The path to the module file that will act as the main entry point.
namestringThe name of the package.
optionalDependencies?IPackageJsonDependencyTable(Optional) An array of optional dependencies that may be installed for this package.
peerDependencies?IPackageJsonDependencyTable(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.
private?boolean(Optional) Indicates whether this package is allowed to be published or not.
repository?string | IPackageJsonRepository(Optional) The URL of the project's repository.
resolutions?Record<string, string>(Optional) A table of package version resolutions. This feature is only implemented by the Yarn package manager.
scripts?IPackageJsonScriptTable(Optional) A table of script hooks that a package manager or build tool may invoke.
tsdocMetadata?string(BETA) (Optional) The path to the TSDoc metadata file. This is still being standardized: https://github.com/microsoft/tsdoc/issues/7\#issuecomment-442271815
types?string(Optional) The path to the TypeScript *.d.ts file describing the module file that will act as the main entry point.
typings?string(Optional) Alias for types
version?string(Optional) A version number conforming to the Semantic Versioning (SemVer) standard.