package.json Fields Reference

Every package.json field with type, semantics and npm/bundler behavior notes

Searchable reference of package.json fields covering name, version, exports, scripts, dependencies, bin, files, type, and engines. Each entry lists the value type, what npm and bundlers do with it, and common pitfalls.

What is the exports field for?

The exports field defines the public entry points of a package and, when present, hides every other internal file from importers. It supports conditional resolution so you can ship separate ESM and CommonJS builds and map subpaths like ./utils to specific files.

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:

  • Identityname, version, private, license.
  • Entry pointsmain, module, types, exports, bin, type.
  • Dependenciesdependencies, devDependencies, peerDependencies, optionalDependencies.
  • Publishingfiles, publishConfig, engines, os, cpu.
  • Toolingscripts, 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.