1 import {LiteralUnion} from './literal-union';
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 {
30 [directoryType: string]: unknown;
33 Location for executable scripts. Sugar to generate entries in the `bin` property by walking the folder.
38 Location for Markdown files.
43 Location for example scripts.
48 Location for the bulk of the library.
53 Location for man pages. Sugar to generate a `man` array by walking the folder.
58 Location for test files.
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;
203 } & Record<string, string>;
206 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.
208 export type Dependency = Record<string, string>;
211 Conditions which provide a way to resolve a package entry point based on the environment.
213 export type ExportCondition = LiteralUnion<
226 Entry points of a module, optionally with conditions and subpath exports.
228 export type Exports =
230 | {[key in ExportCondition]: Exports}
231 | {[key: string]: Exports}; // eslint-disable-line @typescript-eslint/consistent-indexed-object-style
233 export interface NonStandardEntryPoints {
235 An ECMAScript module ID that is the primary entry point to the program.
240 A module ID with untranspiled code that is the primary entry point to the program.
245 [moduleName: string]: string | undefined;
251 A hint to JavaScript bundlers or component tools when packaging modules for client side use.
255 | Record<string, string | false>;
258 Denote which files in your project are "pure" and therefore safe for Webpack to prune if unused.
260 [Read more.](https://webpack.js.org/guides/tree-shaking/)
262 sideEffects?: boolean | string[];
265 export interface TypeScriptConfiguration {
267 Location of the bundled TypeScript declaration file.
272 Location of the bundled TypeScript declaration file. Alias of `types`.
278 An alternative configuration for Yarn workspaces.
280 export interface WorkspaceConfig {
282 An array of workspace pattern strings which contain the workspace packages.
284 packages?: WorkspacePattern[];
287 Designed to solve the problem of packages which break when their `node_modules` are moved to the root workspace directory - a process known as hoisting. For these packages, both within your workspace, and also some that have been installed via `node_modules`, it is important to have a mechanism for preventing the default Yarn workspace behavior. By adding workspace pattern strings here, Yarn will resume non-workspace behavior for any package which matches the defined patterns.
289 [Read more](https://classic.yarnpkg.com/blog/2018/02/15/nohoist/)
291 nohoist?: WorkspacePattern[];
295 A workspace pattern points to a directory or group of directories which contain packages that should be included in the workspace installation process.
297 The patterns are handled with [minimatch](https://github.com/isaacs/minimatch).
300 `docs` → Include the docs directory and install its dependencies.
301 `packages/*` → Include all nested directories within the packages directory, like `packages/cli` and `packages/core`.
303 type WorkspacePattern = string;
305 export interface YarnConfiguration {
307 Used to configure [Yarn workspaces](https://classic.yarnpkg.com/docs/workspaces/).
309 Workspaces allow you to manage multiple packages within the same repository in such a way that you only need to run `yarn install` once to install all of them in a single pass.
311 Please note that the top-level `private` property of `package.json` **must** be set to `true` in order to use workspaces.
313 workspaces?: WorkspacePattern[] | WorkspaceConfig;
316 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`.
318 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 app), those other packages will also need `"flat": true` in their `package.json` or be installed with `yarn install --flat` on the command-line.
323 Selective version resolutions. Allows the definition of custom package versions inside dependencies without manual edits in the `yarn.lock` file.
325 resolutions?: Dependency;
328 export interface JSPMConfiguration {
336 Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Containing standard npm properties.
338 export interface PackageJsonStandard {
340 The name of the package.
345 Package version, parseable by [`node-semver`](https://github.com/npm/node-semver).
350 Package description, listed in `npm search`.
352 description?: string;
355 Keywords associated with package, listed in `npm search`.
360 The URL to the package's homepage.
362 homepage?: LiteralUnion<'.', string>;
365 The URL to the package's issue tracker and/or the email address to which issues should be reported.
370 The license for the package.
375 The licenses for the package.
385 A list of people who contributed to the package.
387 contributors?: Person[];
390 A list of people who maintain the package.
392 maintainers?: Person[];
395 The files included in the package.
400 Resolution algorithm for importing ".js" files from the package's scope.
402 [Read more.](https://nodejs.org/api/esm.html#esm_package_json_type_field)
404 type?: 'module' | 'commonjs';
407 The module ID that is the primary entry point to the program.
412 Standard entry points of the package, with enhanced support for ECMAScript Modules.
414 [Read more.](https://nodejs.org/api/esm.html#esm_package_entry_points)
419 The executable files that should be installed into the `PATH`.
423 | Record<string, string>;
426 Filenames to put in place for the `man` program to find.
428 man?: string | string[];
431 Indicates the structure of the package.
433 directories?: DirectoryLocations;
436 Location for the code repository.
445 Relative path to package.json if it is placed in non-root directory (for example if it is part of a monorepo).
447 [Read more.](https://github.com/npm/rfcs/blob/latest/implemented/0010-monorepo-subdirectory-declaration.md)
453 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.
458 Is used to set configuration parameters used in package scripts that persist across upgrades.
460 config?: Record<string, unknown>;
463 The dependencies of the package.
465 dependencies?: Dependency;
468 Additional tooling dependencies that are not required for the package to work. Usually test, build, or documentation tooling.
470 devDependencies?: Dependency;
473 Dependencies that are skipped if they fail to install.
475 optionalDependencies?: Dependency;
478 Dependencies that will usually be required by the package user directly or via another dependency.
480 peerDependencies?: Dependency;
483 Indicate peer dependencies that are optional.
485 peerDependenciesMeta?: Record<string, {optional: true}>;
488 Package names that are bundled when the package is published.
490 bundledDependencies?: string[];
493 Alias of `bundledDependencies`.
495 bundleDependencies?: string[];
498 Engines that this package runs on.
501 [EngineName in 'npm' | 'node' | string]: string;
507 engineStrict?: boolean;
510 Operating systems the module runs on.
512 os?: Array<LiteralUnion<
531 CPU architectures the module runs on.
533 cpu?: Array<LiteralUnion<
560 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.
564 preferGlobal?: boolean;
567 If set to `true`, then npm will refuse to publish it.
572 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.
574 publishConfig?: Record<string, unknown>;
577 Describes and notifies consumers of a package's monetary support information.
579 [Read more.](https://github.com/npm/rfcs/blob/latest/accepted/0017-add-funding-support.md)
596 The URL to the funding page.
604 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.
606 export type PackageJson =
607 PackageJson.PackageJsonStandard &
608 PackageJson.NonStandardEntryPoints &
609 PackageJson.TypeScriptConfiguration &
610 PackageJson.YarnConfiguration &
611 PackageJson.JSPMConfiguration;