package.json is the manifest npm, bundlers, and Node read to understand your
package. A single misplaced field can break imports for every consumer or
silently publish your entire working tree. This is a searchable reference of the
fields you actually touch, with what each one does and where it bites.
How it works
Each field has a defined value type (string, object, array, or boolean) and is read by a specific tool: npm for install and publish behavior, Node for module resolution, and bundlers for entry-point selection. The reference groups fields by purpose:
- Identity —
name,version,private,license. - Entry points —
main,module,types,exports,bin,type. - Dependencies —
dependencies,devDependencies,peerDependencies,optionalDependencies. - Publishing —
files,publishConfig,engines,os,cpu. - Tooling —
scripts,workspaces.
Tips and gotchas
The modern resolution order is exports first (if present, it overrides
main), then main for legacy. Always ship a types or typesVersions
mapping so TypeScript consumers get types. Remember that an exports map
encapsulates the package — anything not listed becomes unreachable, which
catches teams that relied on deep imports. For dual ESM/CJS packages, pair
type with conditional exports so the right file loads under import versus
require.