1 import {LiteralUnion} from '..';
3 declare namespace PackageJson {
5 A person who has been involved in creating or maintaining the package.
15 export type BugsLocation =
19 The URL to the package's issue tracker.
24 The email address to which issues should be reported.
29 export interface DirectoryLocations {
31 Location for executable scripts. Sugar to generate entries in the `bin` property by walking the folder.
36 Location for Markdown files.
41 Location for example scripts.
46 Location for the bulk of the library.
51 Location for man pages. Sugar to generate a `man` array by walking the folder.
56 Location for test files.
60 [directoryType: string]: unknown;
63 export type Scripts = {
65 Run **before** the package is published (Also run on local `npm install` without any arguments).
70 Run both **before** the package is packed and published, and on local `npm install` without any arguments. This is run **after** `prepublish`, but **before** `prepublishOnly`.
75 Run **before** the package is prepared and packed, **only** on `npm publish`.
77 prepublishOnly?: string;
80 Run **before** a tarball is packed (on `npm pack`, `npm publish`, and when installing git dependencies).
85 Run **after** the tarball has been generated and moved to its final destination.
90 Run **after** the package is published.
95 Run **after** the package is published.
100 Run **before** the package is installed.
105 Run **after** the package is installed.
110 Run **after** the package is installed and after `install`.
112 postinstall?: string;
115 Run **before** the package is uninstalled and before `uninstall`.
117 preuninstall?: string;
120 Run **before** the package is uninstalled.
125 Run **after** the package is uninstalled.
127 postuninstall?: string;
130 Run **before** bump the package version and before `version`.
135 Run **before** bump the package version.
140 Run **after** bump the package version.
142 postversion?: string;
145 Run with the `npm test` command, before `test`.
150 Run with the `npm test` command.
155 Run with the `npm test` command, after `test`.
160 Run with the `npm stop` command, before `stop`.
165 Run with the `npm stop` command.
170 Run with the `npm stop` command, after `stop`.
175 Run with the `npm start` command, before `start`.
180 Run with the `npm start` command.
185 Run with the `npm start` command, after `start`.
190 Run with the `npm restart` command, before `restart`. Note: `npm restart` will run the `stop` and `start` scripts if no `restart` script is provided.
195 Run with the `npm restart` command. Note: `npm restart` will run the `stop` and `start` scripts if no `restart` script is provided.
200 Run with the `npm restart` command, after `restart`. Note: `npm restart` will run the `stop` and `start` scripts if no `restart` script is provided.
202 postrestart?: string;
204 [scriptName: string]: string;
208 Dependencies of the package. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or Git URL.
210 export interface Dependency {
211 [packageName: string]: string;
214 export interface NonStandardEntryPoints {
216 An ECMAScript module ID that is the primary entry point to the program.
221 A module ID with untranspiled code that is the primary entry point to the program.
228 [moduleName: string]: string | undefined;
232 A hint to JavaScript bundlers or component tools when packaging modules for client side use.
237 [moduleName: string]: string | false;
241 export interface TypeScriptConfiguration {
243 Location of the bundled TypeScript declaration file.
248 Location of the bundled TypeScript declaration file. Alias of `types`.
253 export interface YarnConfiguration {
255 If your package only allows one version of a given dependency, and you’d like to enforce the same behavior as `yarn install --flat` on the command line, set this to `true`.
257 Note that if your `package.json` contains `"flat": true` and other packages depend on yours (e.g. you are building a library rather than an application), those other packages will also need `"flat": true` in their `package.json` or be installed with `yarn install --flat` on the command-line.
262 Selective version resolutions. Allows the definition of custom package versions inside dependencies without manual edits in the `yarn.lock` file.
264 resolutions?: Dependency;
267 export interface JSPMConfiguration {
276 Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Also includes types for fields used by other popular projects, like TypeScript and Yarn.
278 export type PackageJson = {
280 The name of the package.
285 Package version, parseable by [`node-semver`](https://github.com/npm/node-semver).
290 Package description, listed in `npm search`.
292 description?: string;
295 Keywords associated with package, listed in `npm search`.
300 The URL to the package's homepage.
302 homepage?: LiteralUnion<'.', string>;
305 The URL to the package's issue tracker and/or the email address to which issues should be reported.
307 bugs?: PackageJson.BugsLocation;
310 The license for the package.
315 The licenses for the package.
322 author?: PackageJson.Person;
325 A list of people who contributed to the package.
327 contributors?: PackageJson.Person[];
330 A list of people who maintain the package.
332 maintainers?: PackageJson.Person[];
335 The files included in the package.
340 The module ID that is the primary entry point to the program.
345 The executable files that should be installed into the `PATH`.
350 [binary: string]: string;
354 Filenames to put in place for the `man` program to find.
356 man?: string | string[];
359 Indicates the structure of the package.
361 directories?: PackageJson.DirectoryLocations;
364 Location for the code repository.
374 Script commands that are run at various times in the lifecycle of the package. The key is the lifecycle event, and the value is the command to run at that point.
376 scripts?: PackageJson.Scripts;
379 Is used to set configuration parameters used in package scripts that persist across upgrades.
382 [configKey: string]: unknown;
386 The dependencies of the package.
388 dependencies?: PackageJson.Dependency;
391 Additional tooling dependencies that are not required for the package to work. Usually test, build, or documentation tooling.
393 devDependencies?: PackageJson.Dependency;
396 Dependencies that are skipped if they fail to install.
398 optionalDependencies?: PackageJson.Dependency;
401 Dependencies that will usually be required by the package user directly or via another dependency.
403 peerDependencies?: PackageJson.Dependency;
406 Package names that are bundled when the package is published.
408 bundledDependencies?: string[];
411 Alias of `bundledDependencies`.
413 bundleDependencies?: string[];
416 Engines that this package runs on.
419 [EngineName in 'npm' | 'node' | string]: string;
425 engineStrict?: boolean;
428 Operating systems the module runs on.
430 os?: Array<LiteralUnion<
449 CPU architectures the module runs on.
451 cpu?: Array<LiteralUnion<
478 If set to `true`, a warning will be shown if package is installed locally. Useful if the package is primarily a command-line application that should be installed globally.
482 preferGlobal?: boolean;
485 If set to `true`, then npm will refuse to publish it.
490 * A set of config values that will be used at publish-time. It's especially handy to set the tag, registry or access, to ensure that a given package is not tagged with 'latest', published to the global public registry or that a scoped module is private by default.
493 [config: string]: unknown;
496 PackageJson.NonStandardEntryPoints &
497 PackageJson.TypeScriptConfiguration &
498 PackageJson.YarnConfiguration &
499 PackageJson.JSPMConfiguration & {
500 [key: string]: unknown;