Optional ReadonlyauthorPackage author information. An author is one person.
your-name <account@your-domain> (http://your-url)
Optional ReadonlybinAn 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.
Optional ReadonlybrowserThis is a hint to the module which is meant to be used "client-side" instead of "nodejs".
Can be a string pointing to the browser entry point:
{
"browser": "./lib/browser.js"
}
Or an object mapping Node.js modules to browser alternatives:
{
"browser": {
"./lib/server.js": "./lib/browser.js",
"fs": false
}
}
Optional ReadonlybugsThe 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.
Optional ReadonlybundledBundled dependencies are an array of package names that will be bundled together when publishing your package.
Optional ReadonlybundleAlias for bundledDependencies.
Both spellings are supported by npm.
Optional ReadonlyconfigA "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.
Optional ReadonlycontributorsIf there is an AUTHORS file in the root of your package,
npm will treat each line as a Name
Optional ReadonlycpuIf your code only runs on certain cpu architectures, you can specify which ones.
This checks against process.arch.
Optional ReadonlydependenciesDependencies 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.
Optional ReadonlydeprecatedA deprecation message for the package.
When set, npm will display a warning when the package is installed.
This is typically set via npm deprecate command, but can also be
set directly in package.json.
{
"deprecated": "This package is no longer maintained. Use 'new-package' instead."
}
Optional ReadonlydescriptionA brief description of the package. By convention, the first sentence (up to the first ". ") should be usable as a package title in listings.
Optional ReadonlydevIf 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.
Optional ReadonlydevDevelopment engine requirements.
Similar to engines, but these requirements only apply during
development (not when the package is used as a dependency).
{
"devEngines": {
"runtime": {
"name": "node",
"version": ">=20.0.0"
},
"packageManager": {
"name": "npm",
"version": ">=10.0.0"
}
}
}
Optional ReadonlydirectoriesYou 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/"
}
}
Optional ReadonlyenginesYou 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.
Optional ReadonlyexportsThe exports field allows defining entry points of a package
when imported by name. It takes precedence over the main field
and allows restricting access to internal modules.
{
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"./utils": "./dist/utils.js"
}
}
Optional ReadonlyfilesFiles 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.
Optional ReadonlyflatIf 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.
Optional ReadonlyfundingFunding information for the package. Provides details on how to financially support the package maintainers.
{
"funding": {
"type": "github",
"url": "https://github.com/sponsors/user"
}
}
Can also be an array for multiple funding sources:
{
"funding": [
{ "type": "github", "url": "https://github.com/sponsors/user" },
{ "type": "opencollective", "url": "https://opencollective.com/project" }
]
}
Optional ReadonlyhomepageThe url to the project homepage.
Optional ReadonlyimportsPackage imports field for creating internal module aliases.
Allows defining import paths that only work within the package itself.
All entries must start with # to distinguish them from package specifiers.
{
"imports": {
"#utils": "./src/utils/index.js",
"#internal/*": "./src/internal/*.js"
}
}
Optional ReadonlyjsdelivrEntry point for jsDelivr CDN. Specifies the file to serve when the package is loaded via jsDelivr.
{
"jsdelivr": "./dist/index.min.js"
}
Optional ReadonlykeywordsAn array of string keywords to assist users searching for the package in catalogs.
Optional ReadonlylibcIf your code only runs with certain C library implementations, you can specify which ones. This checks against the C library used by the Node.js runtime.
{
"libc": ["glibc"]
}
You can also exclude certain implementations:
{
"libc": ["!musl"]
}
Optional ReadonlylicenseA 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.
Optional ReadonlymainThe 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.
Optional ReadonlymaintainersA list of people who maintain this package. This field is managed by npm and may not be directly edited. It's populated from the npm registry.
Optional ReadonlymanA single file (or an array of filenames) for the man program.
Optional ReadonlymoduleThe module field is used by bundlers like webpack and Rollup
to detect the ES module entry point of a package.
This is an unofficial field but widely adopted by the ecosystem.
{
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js"
}
Optional ReadonlynameThe 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.
Optional ReadonlyoptionalIf 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.
Optional ReadonlyosYou can specify which operating systems your module will run on
Optional ReadonlyoverridesAllows overriding versions of nested dependencies. This is useful when you need to fix a security vulnerability or bug in a transitive dependency without waiting for the direct dependency to update.
{
"overrides": {
"foo": "1.0.0",
"bar": {
"baz": "2.0.0"
}
}
}
Optional ReadonlypackageDefines which package manager is expected to be used when working on the current project. This field is managed by Corepack. Setting this field causes Corepack to ensure the specified package manager version is available and to run it transparently.
{
"packageManager": "npm@10.2.0"
}
Or with yarn or pnpm:
{
"packageManager": "pnpm@8.10.0"
}
Optional ReadonlypeerIn 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.
Optional ReadonlypeerProvides metadata about peer dependencies, such as marking them as optional. When a peer dependency is marked as optional, npm will not automatically install it and will not emit a warning if it's missing.
{
"peerDependencies": {
"react": "^18.0.0",
"typescript": "^5.0.0"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
}
Optional ReadonlypreferThis 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.
Optional ReadonlyprivateIf 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.
Optional ReadonlypublishThis 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.
{
"publishConfig":{
"registry":"https://registry.npmjs.org"
}
}
{
"publishConfig":{
"registry":"http://your-registry.local"
}
}
Optional ReadonlyrepositorySpecify the place where your code lives. This is helpful for people who want to contribute.
{
"repository": {
"type": "git",
"url": "https://github.com/ajaxlab/package-json-type.git"
}
}
{
"repository": {
"type": "svn",
"url": "https://v8.googlecode.com/svn/trunk/"
}
}
{
"repository": {
"type": "git",
"url": "https://github.com/facebook/react.git",
"directory": "packages/react-dom"
}
}
Optional ReadonlyresolutionsAllows 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.
Optional ReadonlyscriptsThe "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 ReadonlysideIndicates whether the package has side effects for tree-shaking purposes.
When set to false, bundlers like webpack can safely remove
unused exports from the bundle.
{
"sideEffects": false
}
Can also be an array of files that have side effects:
{
"sideEffects": [
"./src/polyfills.js",
"*.css"
]
}
Optional ReadonlytypeDefines the module format for .js files in the package scope.
When set to "module", .js files are treated as ES modules.
When set to "commonjs" (default), .js files are treated as CommonJS.
{
"type": "module"
}
Optional ReadonlytypesIndicate 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"
}
Optional ReadonlytypesAllows providing different type definitions for different TypeScript versions. This is useful when your package uses features that are only available in newer TypeScript versions.
{
"typesVersions": {
">=4.0": {
"*": ["ts4.0/*"]
},
">=3.0": {
"*": ["ts3.0/*"]
}
}
}
Optional ReadonlytypingsAlias for types. Used to indicate the main TypeScript declaration file.
This is the older name for the field, but is still widely supported.
Optional ReadonlyunpkgEntry point for unpkg CDN. Specifies the file to serve when the package is loaded via unpkg.
{
"unpkg": "./dist/index.umd.min.js"
}
Optional ReadonlyversionA version string conforming to the Semantic Versioning requirements.
Optional ReadonlyworkspacesWorkspaces allow you to manage multiple packages within a single repository (monorepo). Define the workspace packages using glob patterns.
{
"workspaces": [
"packages/*",
"apps/*"
]
}
Can also be an object with more options:
{
"workspaces": {
"packages": ["packages/*"],
"nohoist": ["**/react-native"]
}
}
A TypeScript definition for the package descriptor file.
See