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