Type for npm's package.json file. Containing standard npm properties.

interface PackageJsonStandard {
    author?: Person;
    bin?: string | Partial<Record<string, string>>;
    bugs?: BugsLocation;
    bundledDependencies?: string[];
    bundleDependencies?: string[];
    config?: JsonObject;
    contributors?: Person[];
    cpu?: LiteralUnion<
        | "arm"
        | "arm64"
        | "ia32"
        | "mips"
        | "mipsel"
        | "ppc"
        | "ppc64"
        | "s390"
        | "s390x"
        | "x32"
        | "x64"
        | "!arm"
        | "!arm64"
        | "!ia32"
        | "!mips"
        | "!mipsel"
        | "!ppc"
        | "!ppc64"
        | "!s390"
        | "!s390x"
        | "!x32"
        | "!x64",
        string,
    >[];
    dependencies?: Partial<Record<string, string>>;
    description?: string;
    devDependencies?: Partial<Record<string, string>>;
    directories?: DirectoryLocations;
    engines?: { [key: string]: undefined | string };
    engineStrict?: boolean;
    exports?: Exports;
    files?: string[];
    funding?:
        | string
        | {
            type?: LiteralUnion<
                | "github"
                | "opencollective"
                | "patreon"
                | "individual"
                | "foundation"
                | "corporation",
                string,
            >;
            url: string;
        };
    homepage?: LiteralUnion<".", string>;
    imports?: Imports;
    keywords?: string[];
    license?: string;
    licenses?: { type?: string; url?: string }[];
    main?: string;
    maintainers?: Person[];
    man?: string | string[];
    name?: string;
    optionalDependencies?: Partial<Record<string, string>>;
    os?: LiteralUnion<
        | "aix"
        | "darwin"
        | "freebsd"
        | "linux"
        | "openbsd"
        | "sunos"
        | "win32"
        | "!aix"
        | "!darwin"
        | "!freebsd"
        | "!linux"
        | "!openbsd"
        | "!sunos"
        | "!win32",
        string,
    >[];
    peerDependencies?: Partial<Record<string, string>>;
    peerDependenciesMeta?: Partial<Record<string, { optional: true }>>;
    preferGlobal?: boolean;
    private?: boolean;
    publishConfig?: PublishConfig;
    repository?: string | { directory?: string; type: string; url: string };
    scripts?: Scripts;
    type?: "module" | "commonjs";
    version?: string;
    workspaces?: string[] | WorkspaceConfig;
}

Properties

author?: Person
bin?: string | Partial<Record<string, string>>

The executable files that should be installed into the PATH.

The URL to the package's issue tracker and/or the email address to which issues should be reported.

bundledDependencies?: string[]

Package names that are bundled when the package is published.

bundleDependencies?: string[]

Alias of bundledDependencies.

config?: JsonObject

Is used to set configuration parameters used in package scripts that persist across upgrades.

contributors?: Person[]

A list of people who contributed to the package.

cpu?: LiteralUnion<
    | "arm"
    | "arm64"
    | "ia32"
    | "mips"
    | "mipsel"
    | "ppc"
    | "ppc64"
    | "s390"
    | "s390x"
    | "x32"
    | "x64"
    | "!arm"
    | "!arm64"
    | "!ia32"
    | "!mips"
    | "!mipsel"
    | "!ppc"
    | "!ppc64"
    | "!s390"
    | "!s390x"
    | "!x32"
    | "!x64",
    string,
>[]

CPU architectures the module runs on.

dependencies?: Partial<Record<string, string>>

The dependencies of the package.

description?: string

Package description, listed in npm search.

devDependencies?: Partial<Record<string, string>>

Additional tooling dependencies that are not required for the package to work. Usually test, build, or documentation tooling.

directories?: DirectoryLocations

Indicates the structure of the package.

engines?: { [key: string]: undefined | string }

Engines that this package runs on.

engineStrict?: boolean
exports?: Exports

Subpath exports to define entry points of the package.

Read more.

files?: string[]

The files included in the package.

funding?:
    | string
    | {
        type?: LiteralUnion<
            | "github"
            | "opencollective"
            | "patreon"
            | "individual"
            | "foundation"
            | "corporation",
            string,
        >;
        url: string;
    }

Describes and notifies consumers of a package's monetary support information.

Read more.

Type declaration

  • string
  • {
        type?: LiteralUnion<
            | "github"
            | "opencollective"
            | "patreon"
            | "individual"
            | "foundation"
            | "corporation",
            string,
        >;
        url: string;
    }
    • Optionaltype?: LiteralUnion<
          | "github"
          | "opencollective"
          | "patreon"
          | "individual"
          | "foundation"
          | "corporation",
          string,
      >

      The type of funding.

    • url: string

      The URL to the funding page.

homepage?: LiteralUnion<".", string>

The URL to the package's homepage.

imports?: Imports

Subpath imports to define internal package import maps that only apply to import specifiers from within the package itself.

Read more.

keywords?: string[]

Keywords associated with package, listed in npm search.

license?: string

The license for the package.

licenses?: { type?: string; url?: string }[]

The licenses for the package.

main?: string

The module ID that is the primary entry point to the program.

maintainers?: Person[]

A list of people who maintain the package.

man?: string | string[]

Filenames to put in place for the man program to find.

name?: string

The name of the package.

optionalDependencies?: Partial<Record<string, string>>

Dependencies that are skipped if they fail to install.

os?: LiteralUnion<
    | "aix"
    | "darwin"
    | "freebsd"
    | "linux"
    | "openbsd"
    | "sunos"
    | "win32"
    | "!aix"
    | "!darwin"
    | "!freebsd"
    | "!linux"
    | "!openbsd"
    | "!sunos"
    | "!win32",
    string,
>[]

Operating systems the module runs on.

peerDependencies?: Partial<Record<string, string>>

Dependencies that will usually be required by the package user directly or via another dependency.

peerDependenciesMeta?: Partial<Record<string, { optional: true }>>

Indicate peer dependencies that are optional.

preferGlobal?: boolean

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.

private?: boolean

If set to true, then npm will refuse to publish it.

publishConfig?: PublishConfig

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.

repository?: string | { directory?: string; type: string; url: string }

Location for the code repository.

Type declaration

  • string
  • { directory?: string; type: string; url: string }
    • Optionaldirectory?: string

      Relative path to package.json if it is placed in non-root directory (for example if it is part of a monorepo).

      Read more.

    • type: string
    • url: string
scripts?: Scripts

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.

type?: "module" | "commonjs"

Resolution algorithm for importing ".js" files from the package's scope.

Read more.

version?: string

Package version, parseable by node-semver.

workspaces?: string[] | WorkspaceConfig

Used to configure npm workspaces / Yarn workspaces.

Workspaces allow you to manage multiple packages within the same repository in such a way that you only need to run your install command once in order to install all of them in a single pass.

Please note that the top-level private property of package.json must be set to true in order to use workspaces.