Registry / devops / normalize-pkg

normalize-pkg

JSON →
library0.5.0jsnpmunverified

Library for normalizing package.json files using a schema-based approach. Version 0.5.0 (last released 2019) is stable but in maintenance mode. It standardizes fields like repository, author, license, and bin, and can infer missing values from the filesystem. Unlike simple validation tools, it transforms and completes package.json objects according to configurable schema rules. Suitable for CLI tools, scaffolding, or build processes that need consistent package metadata.

devops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

The package exports a single function; default import is recommended for ESM. CJS require also works.

import normalizePkg from 'normalize-pkg'

The constructor is the default export; named import is incorrect.

import NormalizePkg from 'normalize-pkg'

Options must be passed to the constructor; setting afterwards may not apply correctly.

import NormalizePkg from 'normalize-pkg'; const pkg = new NormalizePkg({ knownOnly: true });

Demonstrates importing normalize-pkg, creating an instance, and normalizing a package.json object. Note: uses import assertions for JSON modules.

import NormalizePkg from 'normalize-pkg'; import pkgJson from './package.json' assert { type: 'json' }; const normalizer = new NormalizePkg(); const normalized = normalizer.normalize(pkgJson); console.log(JSON.stringify(normalized, null, 2));
Debug
Known footguns
gotchaOptions like knownOnly must be passed to the constructor, not set after instantiation.
gotchaThe normalize() method mutates the input object; pass a copy if you need to preserve the original.
deprecatedBower install instructions in README are outdated; Bower is deprecated.
gotchaSome normalizers (e.g., bin) rely on the filesystem and may fail if the current working directory is not a package root.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
3
ahrefsbot
1
Resources