Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IPackageJson

Hierarchy

  • IPackageJson

Indexable

[field: string]: any

A TypeScript definition for the package descriptor file.

Index

Properties

Optional author

author: string | IAuthor

Package author information. An author is one person.

  • Shorthand expression
    your-name <account@your-domain> (http://your-url)
see

https://docs.npmjs.com/files/package.json#people-fields-author-contributors

see

https://yarnpkg.com/en/docs/package-json#toc-author

Optional bin

bin: string | IBinMap

An executable file which will be installed into the PATH with a package install. npm will symlink that file into prefix/bin for global installs, or ./node_modules/.bin/ for local installs.

{
  "bin" : {
    "myapp" : "./cli.js"
  }
}

For example, with linux if you install myapp, it'll create a symlink from the cli.js script to /usr/local/bin/myapp.

see

https://docs.npmjs.com/files/package.json#bin

Optional browser

browser: undefined | string

Optional bugs

bugs: string | IBugs

The url to your project's issue tracker and (or) the email address to which issues should be reported. These are helpful for people who encounter issues with your package.

see

https://docs.npmjs.com/files/package.json#bugs

see

https://yarnpkg.com/en/docs/package-json#toc-bugs

Optional bundledDependencies

bundledDependencies: string[]

Bundled dependencies are an array of package names that will be bundled together when publishing your package.

see

https://docs.npmjs.com/files/package.json#bundleddependencies

see

https://yarnpkg.com/en/docs/package-json#toc-bundleddependencies

Optional config

config: IConfig

A "config" object can be used to set configuration parameters used in package scripts that persist across upgrades. For instance, if a package had the following:

{
  "config" : {
    "port" : "8080"
  }
}

and then had a "start" command that then referenced the npm_package_config_port environment variable, then the user could override that by doing npm config set foo:port 8001.

see

https://docs.npmjs.com/files/package.json#config

see

https://yarnpkg.com/en/docs/package-json#toc-config

Optional contributors

contributors: Array<IAuthor | string>

If there is an AUTHORS file in the root of your package, npm will treat each line as a Name (url) format, where email and url are optional. Lines which start with a # or are blank, will be ignored.

see

https://docs.npmjs.com/files/package.json#people-fields-author-contributors

see

https://yarnpkg.com/en/docs/package-json#toc-contributors

Optional cpu

cpu: CPU[]

If your code only runs on certain cpu architectures, you can specify which ones. This checks against process.arch.

see

https://docs.npmjs.com/files/package.json#cpu

see

https://yarnpkg.com/en/docs/package-json#toc-cpu

see

https://nodejs.org/api/process.html#process_process_arch

Optional dependencies

dependencies: IDependencyMap

Dependencies are specified in a simple object that maps a package name to a version range. 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.

see

http://wiki.commonjs.org/wiki/Packages/1.0

see

https://docs.npmjs.com/files/package.json#dependencies

see

https://yarnpkg.com/en/docs/package-json#toc-dependencies

Optional description

description: undefined | string

A brief description of the package. By convention, the first sentence (up to the first ". ") should be usable as a package title in listings.

see

https://docs.npmjs.com/files/package.json#description-1

see

http://wiki.commonjs.org/wiki/Packages/1.0

see

https://yarnpkg.com/en/docs/package-json#toc-description

Optional devDependencies

devDependencies: IDependencyMap

If someone is planning on downloading and using your module in their program, then they probably don't want or need to download and build the external test or documentation framework that you use. In this case, it's best to map these additional items in a devDependencies object.

see

https://docs.npmjs.com/files/package.json#devdependencies

see

https://yarnpkg.com/en/docs/package-json#toc-devdependencies

Optional directories

directories: IDirectories

You can specify exact locations to put binary files, man pages, documentation, examples, etc. Package manager tools must use these directory definitions to find various package components.

{
  "directories": {
    "lib": "path/to/lib/",
    "bin": "path/to/bin/",
    "man": "path/to/man/",
    "doc": "path/to/doc/",
    "example": "path/to/example/"
  }
}
see

http://wiki.commonjs.org/wiki/Packages/1.0

see

https://docs.npmjs.com/files/package.json#directories

see

https://yarnpkg.com/en/docs/package-json#toc-directories

Optional engines

engines: IEngines

You can specify the version of node that your stuff works on. You can also specify which versions of npm are capable of properly installing your program.

see

https://docs.npmjs.com/files/package.json#engines

see

https://yarnpkg.com/en/docs/package-json#toc-engines

Optional files

files: string[]

Files that are included in your project described as a glob pattern. Omitting the field will make it default to ["*"], as it will include all files.

see

https://docs.npmjs.com/files/package.json#files

see

https://yarnpkg.com/en/docs/package-json#toc-files

Optional flat

flat: undefined | false | true

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.

see

https://yarnpkg.com/en/docs/package-json#toc-flat

Optional homepage

homepage: undefined | string

Optional keywords

keywords: string[]

An array of string keywords to assist users searching for the package in catalogs.

see

https://docs.npmjs.com/files/package.json#keywords

see

https://yarnpkg.com/en/docs/package-json#toc-keywords

Optional license

A license for your package so that people know how they are permitted to use it, and any restrictions you're placing on it. If you're using a common license such as BSD-2-Clause or MIT, add a current SPDX license identifier.

see

https://docs.npmjs.com/files/package.json#license

see

https://yarnpkg.com/en/docs/package-json#toc-license

see

https://spdx.org/licenses/

see

https://help.github.com/en/articles/licensing-a-repository

Optional main

main: undefined | string

The main field is a module ID that is the primary entry point to your package. That is, if your package is named foo, and a user installs it, and then does require("foo"), then your main module's exports object will be returned. This should be a module ID relative to the root of your package folder. For most modules, it makes the most sense to have a main script and often not much else.

see

https://docs.npmjs.com/files/package.json#main

see

https://yarnpkg.com/en/docs/package-json#toc-main

Optional man

man: string | string[]

A single file (or an array of filenames) for the man program.

see

https://docs.npmjs.com/files/package.json#man

Optional name

name: undefined | string

The name of your package. The name and version together should form a unique identifier accoss a project. The name and version fields are optional if you don't want to publish your package. A name can be optionally prefixed by a scope, e.g. @types/lodash.

see

https://docs.npmjs.com/files/package.json#name

see

https://yarnpkg.com/en/docs/package-json#toc-name

Optional optionalDependencies

optionalDependencies: IDependencyMap

If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the optionalDependencies object. This is a map of package name to version or url, just like the dependencies object. The difference is that build failures do not cause installation to fail. It is still your program's responsibility to handle the lack of the dependency.

see

https://docs.npmjs.com/files/package.json#optionaldependencies

see

https://yarnpkg.com/en/docs/package-json#toc-optionaldependencies

Optional os

os: OS[]

Optional peerDependencies

peerDependencies: IDependencyMap

In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a require of this host. This is usually referred to as a plugin. Notably, your module may be exposing a specific interface, expected and specified by the host documentation.

see

https://docs.npmjs.com/files/package.json#peerdependencies

see

https://yarnpkg.com/en/docs/package-json#toc-peerdependencies

Optional preferGlobal

preferGlobal: undefined | false | true

This option used to trigger an npm warning, but it will no longer warn. It is purely there for informational purposes. It is now recommended that you install any binaries as local devDependencies wherever possible.

deprecated

Optional private

private: undefined | false | true

If you set "private": true in your package.json, then npm will refuse to publish it. This is a way to prevent accidental publication of private repositories. If you would like to ensure that a given package is only ever published to a specific registry (for example, an internal registry), then use the publishConfig dictionary described below to override the registry config param at publish-time.

see

https://docs.npmjs.com/files/package.json#private

see

https://yarnpkg.com/en/docs/package-json#toc-private

Optional publishConfig

publishConfig: IPublishConfig

This is a set of config values that will be used at publish-time. It's especially handy if you want to set the tag, registry or access, so that you can 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. Any config values can be overridden, but only "tag", "registry" and "access" probably matter for the purposes of publishing. See npm-config to see the list of config options that can be overridden.

  • Public Registry
{
  "publishConfig":{
    "registry":"https://registry.npmjs.org"
  }
}
  • Your Private Registry
{
  "publishConfig":{
    "registry":"http://your-registry.local"
  }
}
see

https://docs.npmjs.com/files/package.json#publishconfig

see

https://yarnpkg.com/en/docs/package-json#toc-publishconfig

Optional repository

repository: string | IRepository

Specify the place where your code lives. This is helpful for people who want to contribute.

  • Git
{
  "repository": {
    "type": "git",
    "url": "https://github.com/ajaxlab/package-json-type.git"
  }
}
  • Svn
{
  "repository": {
    "type": "svn",
    "url": "https://v8.googlecode.com/svn/trunk/"
  }
}
  • Monorepo
{
  "repository": {
    "type": "git",
    "url": "https://github.com/facebook/react.git",
    "directory": "packages/react-dom"
  }
}
see

https://yarnpkg.com/en/docs/package-json#toc-repository

see

https://docs.npmjs.com/files/package.json#repository

Optional resolutions

resolutions: undefined | object

Allows you to override a version of a particular nested dependency. See the Selective Versions Resolutions RFC for the full spec. Note that installing dependencies via [yarn install --flat] will automatically add a resolutions block to your package.json file.

see

https://yarnpkg.com/en/docs/package-json#toc-resolutions

Optional scripts

scripts: IScriptsMap | object

The "scripts" property is a dictionary containing script commands that are run at various times in the lifecycle of your package. The key is the lifecycle event, and the value is the command to run at that point.

{
  "scripts": {
    "install": "install.js",
    "uninstall": "uninstall.js",
    "build": "build.js",
    "doc": "make-doc.js",
    "test": "test.js",
  }
}

Optional types

types: undefined | string

Indicate the main declaration file in your package.json. Set the types property to point to your bundled declaration file.

{
  "name": "some-package",
  "version": "1.0.0",
  "main": "./lib/main.js",
  "types": "./lib/main.d.ts"
}
see

https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html

Optional version

version: undefined | string

A version string conforming to the Semantic Versioning requirements.

see

https://docs.npmjs.com/files/package.json#version

see

https://yarnpkg.com/en/docs/package-json#toc-version

Generated using TypeDoc