Skip to content

Manifest (package.json)

{
"title": "JSON Schema for Yarn Manifest files",
"$schema": "https://json-schema.org/draft/2019-09/schema#",
"description": "Manifest files (also called `package.json` because of their name) contain everything needed to describe the settings unique to one particular package. Project will contain multiple such manifests if they use the workspace feature, as each workspace is described through its own manifest. Note that defaults for these fields can be set via the `initFields` settings.",
"__info": [
"This file contains the JSON Schema for Yarn Manifest files and is:",
"1) Hosted on the Yarn Website at http://yarnpkg.com/configuration/manifest.json",
"2) Used to generate the documentation page at http://yarnpkg.com/configuration/manifest",
"Note: Properties prefixed with a single underscore (e.g. exampleItems, _exampleKeys)",
"are unique to our documentation generation interpreter. All others will be picked up",
"by most JSON schema interpreters.",
"Rules:",
"1) Don't set a default if it's null, dynamic, or an object.",
"2) Use `examples` for scalars, `exampleItems` for arrays, and `_exampleKeys` for objects."
],
"type": "object",
"properties": {
"name": {
"title": "Name of the package.",
"description": "Used to identify it across the application, especially amongst multiple workspaces. The first part of the name (here `@scope/`) is optional and is used as a namespace).",
"type": "string",
"pattern": "^(?:@([^/]+?)/)?([^/]+?)$",
"examples": ["@scope/name"]
},
"version": {
"title": "Version of the package.",
"description": "Usually doesn't have any impact on your project, except when it is a workspace - then its version must match the specified ranges for the workspace to be selected as resolution candidate.",
"type": "string",
"pattern": "^(?:(.+))$",
"examples": ["1.2.3"]
},
"packageManager": {
"title": "Define the package manager that should be used when working on this project.",
"description": "This field is used by [Corepack](https://nodejs.org/api/corepack.html) and similar tools to detect the Yarn version in use in a project - in a sense, it has the same purpose as your lockfile, but only for Yarn itself.\n\nYarn will automatically set this value when running `yarn set version`.",
"type": "string",
"format": "uri-reference",
"examples": ["yarn@4.0.0"]
},
"type": {
"title": "Define how should be interpreted `.js` files.",
"description": "A Node.js v13.x [option](https://nodejs.org/api/esm.html#esm_package_json_type_field). Possible values are `commonjs` (the default) and `module`. Yarn 3+ will generate a `.pnp.cjs` file when using PnP regardless of this option.",
"type": "string",
"enum": ["commonjs", "module"],
"default": "commonjs"
},
"private": {
"title": "Define whether the package is meant to be published.",
"description": "If true, the package is considered private and Yarn will refuse to publish it regardless of the circumstances.",
"type": "boolean",
"default": false,
"examples": [true]
},
"license": {
"title": "SPDX identifier defining the license under which the package is distributed.",
"type": "string",
"examples": ["MIT"]
},
"os": {
"title": "Set of platforms on which this package works.",
"description": "The value of `process.platform()` will be compared at install-time against this set. Should no matches be found, any postinstall script the package define will be skipped. If the package was exclusively depended upon via `optionalDependencies` entries, the package won't be installed at all.",
"type": "array",
"items": {
"type": "string"
},
"exampleItems": ["linux", "darwin", "win32"]
},
"cpu": {
"title": "Set of CPU architectures on which this package works.",
"description": "The value of `process.arch()` will be compared at install-time against this set. Should no matches be found, any postinstall script the package define will be skipped. If the package was exclusively depended upon via `optionalDependencies` entries, the package won't be installed at all.",
"type": "array",
"items": {
"type": "string"
},
"exampleItems": ["x64", "ia32", "arm64"]
},
"libc": {
"title": "Set of C standard libraries on which this package depends.",
"description": "The host standard library will be compared at install-time against this set. Should no matches be found, any postinstall script the package define will be skipped. If the package was exclusively depended upon via `optionalDependencies` entries, the package won't be installed at all.",
"type": "array",
"items": {
"type": "string"
},
"exampleItems": ["glibc", "musl"]
},
"main": {
"title": "Path of the file that should be resolved when requiring the package via a bare identifier.",
"description": "This field can be modified at publish-time through the use of the `publishConfig.main` field.",
"type": "string",
"format": "uri-reference",
"examples": ["./sources/index.js"]
},
"module": {
"title": "Path of the file that should be resolved when requiring the package via a bare identifier in an ES6-compatible bundler environment.",
"description": "This field should be considered deprecated, with `exports` being its official replacement.",
"type": "string",
"format": "uri-reference",
"examples": ["./sources/index.mjs"]
},
"languageName": {
"title": "Arbitrary value selecting the linker to use when installing the dependency.",
"description": "This is an internal package setting that shouldn't be touched unless you really know what you're doing.",
"type": "string",
"default": "node",
"examples": ["node"]
},
"bin": {
"title": "Set of files to expose via `yarn run bin-name` and the shell environment.",
"description": "If set to a string, the binary value will be the package name (not including its scope part).",
"type": "object",
"patternProperties": {
"^(.+)$": {
"type": "string",
"format": "uri-reference",
"examples": ["./dist/my-bin.js"]
}
},
"additionalProperties": false,
"exampleKeys": ["my-bin"],
"_margin": false
},
"scripts": {
"title": "Set of scripts to expose via `yarn run script-name`, or as lifecycle hooks.",
"description": "Scripts in Yarn are executed by a POSIX-like shell which implements most features you would want to use in one-liner scripts. For example you can assign environment variables using the POSIX syntax, and Yarn will make it work across both Linux, OSX, and Windows.",
"type": "object",
"patternProperties": {
"^test$": {
"type": "string",
"examples": ["NODE_OPTIONS='--max-old-space-size=2048' jest"]
},
"^build$": {
"type": "string",
"examples": ["webpack-cli --config ./webpack.config.js"]
},
"^count-words$": {
"type": "string",
"examples": ["echo \"$@\" | wc -w"]
},
"^(.+)$": {
"type": "string"
}
},
"additionalProperties": false,
"exampleKeys": ["test", "build", "count-words"]
},
"dependencies": {
"title": "Set of dependencies that must be made available to the current package in order for it to work properly.",
"description": "Consult the [protocol documentation](/protocols) for more information.",
"type": "object",
"patternProperties": {
"^(?:@([^/]+?)/)?([^/]+?)$": {
"type": "string",
"pattern": "^(.+)$",
"examples": ["^5.0.0"]
}
},
"additionalProperties": false,
"exampleKeys": ["webpack"]
},
"optionalDependencies": {
"title": "Set of dependencies that Yarn should only try to install if the os/cpu/libc fields match those of the host platform.",
"description": "Unlike regular dependencies, those listed in `optionalDependencies` are allowed to have a failing `postinstall` step - in fact, they won't even be installed at all if the os/cpu/libc filters don't cover the host platform.\n\nNote that `optionalDependencies` only cares about whether the package should install/build or not - it should still be resolvable, as otherwise it's impossible to tell whether a failure to retrieve the package metadata is intentional or not.",
"type": "object",
"patternProperties": {
"^(?:@([^/]+?)/)?([^/]+?)$": {
"type": "string",
"pattern": "^(.+)$",
"examples": ["^5.0.0"]
}
},
"additionalProperties": false,
"exampleKeys": ["fsevents"]
},
"devDependencies": {
"title": "Set of dependencies that must be made available to the current package in order for it to work properly as a workspace.",
"description": "Unlike regular dependencies, those listed in `devDependencies` will only be required when the package is installed as part of a workspace project - usually by cloning the project repository then running `yarn install` inside it.",
"type": "object",
"patternProperties": {
"^(?:@([^/]+?)/)?([^/]+?)$": {
"type": "string",
"pattern": "^(.+)$",
"examples": ["^5.0.0"]
}
},
"additionalProperties": false,
"exampleKeys": ["webpack"]
},
"peerDependencies": {
"title": "Set of dependencies that the package must inherit from its ancestor in the dependency tree.",
"description": "The semantic of peer dependencies guarantee that when the package require the dependency, it will be returned the exact same object instance as the one that would be returned to the package's ancestor. This mechanism makes peer dependencies the best way to share singleton states across multiple packages.\n\nAs an extension, Yarn supports \"peer dependencies with default\": dependencies listed in both the `dependencies` and a `peerDependencies` fields will try to solve the peer dependency first, but will fallback to the regular dependency if it can't be satisfied otherwise.",
"type": "object",
"patternProperties": {
"^(?:@([^/]+?)/)?([^/]+?)$": {
"type": "string",
"pattern": "^(.+)$",
"examples": ["*"]
}
},
"additionalProperties": false,
"exampleKeys": ["react", "react-dom"]
},
"workspaces": {
"title": "Array of folder glob patterns referencing the workspaces of the project.",
"description": "Workspaces are an optional feature used by monorepos to split a large project into semi-independent subprojects, each one listing their own set of dependencies. The `workspaces` field is a list of glob patterns that match all directories that should become workspaces of your application. Consult the [workspaces documentation](/features/workspaces) for more information.",
"type": "array",
"items": {
"type": "string"
},
"exampleItems": ["packages/*"]
},
"dependenciesMeta": {
"title": "Extra settings affecting how the `dependencies` and `devDependencies` fields are interpreted.",
"description": "In the context of a workspaced project most of these settings will affect *all workspaces* and as such must be specified at the *root* of the project. Unless noted otherwise, the `dependenciesMeta` field will be ignored if found within a workspace.",
"type": "object",
"patternProperties": {
"^(?:@([^/]+?)/)?([^/]+?)$": {
"type": "object",
"properties": {
"built": {
"title": "Define whether to run the postinstall script or not.",
"description": "If false, the package will never be built (deny-list). This behavior is reversed when the `enableScripts` yarnrc setting is toggled off - when that happens, only packages with `built` explicitly set to `true` will be built (allow-list); as for those with `built` explicitly set to `false`, they will simply see their build script warnings downgraded into simple notices.",
"type": "boolean",
"examples": [false]
},
"optional": {
"title": "Define whether the dependency is optional or not.",
"description": "Unlike most other settings in `dependenciesMeta`, `optional` is allowed anywhere in the dependency tree. It has the exact same effect as `optionalDependencies` - in fact, that's internally what `optionalDependencies` compiles down to.",
"type": "boolean",
"examples": [false]
},
"unplugged": {
"title": "Define whether the package must be unplugged or not.",
"description": "If true, the specified package will be automatically unplugged at install time. This should only be needed for packages that contain scripts in other languages than Javascript (for example `nan` contains C++ headers).",
"type": "boolean",
"examples": [true]
}
},
"_margin": true
}
},
"additionalProperties": false,
"exampleKeys": ["fsevents"]
},
"peerDependenciesMeta": {
"title": "Extra settings affecting how the `peerDependencies` field is interpreted.",
"description": "Unlike `dependenciesMeta`, `peerDependenciesMeta` is allowed in any parts of the dependency tree.",
"type": "object",
"patternProperties": {
"^(?:@([^/]+?)/)?([^/]+?)$": {
"type": "object",
"properties": {
"optional": {
"title": "Define whether to log a warning when the peer dependency can't be satisfied.",
"description": "If true, the selected peer dependency will be marked as optional by the package manager, silencing any warning we would otherwise emit.",
"type": "boolean",
"examples": [true]
}
},
"_margin": true
}
},
"additionalProperties": false,
"exampleKeys": ["react-dom"]
},
"resolutions": {
"description": "This field allows you to instruct Yarn to use a specific resolution (specific package version) instead of anything the resolver would normally pick. This is useful to enforce all your packages to use a single version of a dependency, or backport a fix. The syntax for the resolution key accepts one level of specificity, so all the following examples are correct.\n\nNote: When a path is relative, like it can be with the `file:` and `portal:` protocols, it is resolved relative to the path of the project.\n\nNote: The `resolutions` field can only be set at the root of the project, and will generate a warning if used in any other workspace.",
"title": "Override the resolutions of specific dependencies.",
"type": "object",
"patternProperties": {
"^relay-compiler$": {
"type": "string",
"examples": ["3.0.0"]
},
"^webpack/memory-fs$": {
"type": "string",
"examples": ["0.4.1"]
},
"^@babel/core/json5$": {
"type": "string",
"examples": ["2.1.0"]
},
"^@babel/core/@babel/generator$": {
"type": "string",
"examples": ["7.3.4"]
},
"^@babel/core@npm:7\\.0\\.0/@babel/generator$": {
"type": "string",
"examples": ["7.3.4"]
},
"^(?:(?:@([^/]+?)/)?([^/]+?)/?)+$": {
"type": "string",
"pattern": "^(.+)$"
}
},
"additionalProperties": false,
"exampleKeys": [
"relay-compiler",
"webpack/memory-fs",
"@babel/core/json5",
"@babel/core/@babel/generator",
"@babel/core@npm:7.0.0/@babel/generator"
]
},
"preferUnplugged": {
"title": "Define whether the package must be unplugged or not.",
"description": "While Yarn attempts to reference and load packages directly from their zip archives, it may not always be possible. A heuristic tries to detect cases where zip-loading would be problematic and unpack the files on disk instead but, being just a heuristic, it may report incorrect results.\n\nThe `preferUnplugged` field lets you define yourself, as a package author, whether your package works or not when stored as an archive. If set, it will override the default heuristic.",
"type": "boolean",
"examples": [false]
},
"files": {
"title": "Array of file glob patterns that will be included within the published tarball.",
"description": "File patterns follow a similar syntax to `.gitignore`, but reversed: including a file, directory, or glob pattern (`*`, `**/*`, and such) will make it so that file is included in the tarball when it’s packed. Omitting the field will make it default to `[\"*\"]`, which means it will include all files.\n\nIf this field is missing, Yarn will use the project's `.gitignore` to generate the pack list, or the `.npmignore` file instead if available.\n\nSome special files and directories are also [included](https://github.com/yarnpkg/berry/blob/ab2e84588b1eacb2ec60a751f12b168415224a19/packages/plugin-pack/sources/packUtils.ts#L11) or [excluded](https://github.com/yarnpkg/berry/blob/ab2e84588b1eacb2ec60a751f12b168415224a19/packages/plugin-pack/sources/packUtils.ts#L27) regardless of whether they exist in the `files` array.",
"type": "array",
"items": {
"type": "string",
"format": "uri-reference"
},
"exampleItems": ["dist/**/*", "lib/**/*"]
},
"publishConfig": {
"title": "Extra settings affecting how the package is published.",
"type": "object",
"properties": {
"access": {
"title": "Define the access to use when publishing the package.",
"description": "Valid values are `public` and `restricted`, but `restricted` usually requires to register for a paid plan (this is up to the registry you use).",
"type": "string",
"enum": ["public", "restricted"],
"examples": ["public"]
},
"bin": {
"title": "Replacement of the package's `bin` field, used in the published tarball over the main one.",
"type": "string",
"format": "uri-reference",
"examples": ["./build/bin.js"]
},
"browser": {
"title": "Replacement of the package's `browser` field, used in the published tarball over the main one.",
"type": "string",
"format": "uri-reference",
"examples": ["./build/browser.js"]
},
"executableFiles": {
"title": "Set of files that must be marked as executable (+x) in the published tarball.",
"type": "array",
"items": {
"type": "string",
"format": "uri-reference"
},
"exampleItems": ["./dist/shim.js"]
},
"main": {
"title": "Replacement of the package's `main` field, used in the published tarball over the main one.",
"type": "string",
"format": "uri-reference",
"examples": ["./build/index.js"]
},
"module": {
"title": "Replacement of the package's `module` field, used in the published tarball over the main one.",
"type": "string",
"format": "uri-reference",
"examples": ["./build/index.mjs"]
},
"provenance": {
"title": "Define whether to produce a provenance statement for the package when publishing. Overrides all other provenance settings.",
"type": "boolean",
"examples": [true]
},
"registry": {
"description": "If present, will replace whatever registry is defined in the configuration when the package is about to be pushed to a remote location.",
"type": "string",
"format": "uri",
"examples": ["https://npm.pkg.github.com"]
},
"type": {
"title": "Replacement of the package's `type` field, used in the published tarball over the main one.",
"type": "string",
"format": "uri-reference",
"examples": ["./build/index.d.ts"]
}
},
"_margin": true
},
"installConfig": {
"title": "Extra settings affecting how the package is installed.",
"type": "object",
"properties": {
"hoistingLimits": {
"title": "Defines the highest point where packages can be hoisted.",
"description": "See `nmHoistingLimits` for more information.",
"type": "string",
"enum": ["workspaces", "dependencies", "none"],
"default": "none",
"examples": ["none"]
},
"selfReferences": {
"title": "Defines whether workspaces are allowed to require themselves.",
"description": "See `nmSelfReferences` for more information.",
"type": "boolean",
"default": true,
"examples": [true]
}
},
"_margin": true
}
}
}