{"id":48790,"library":"normalize-pkg","title":"normalize-pkg","description":"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.","status":"maintenance","version":"0.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/jonschlinkert/normalize-pkg","tags":["javascript","config","fix","json","normalize","package","package-json","pkg","properties"],"install":[{"cmd":"npm install normalize-pkg","lang":"bash","label":"npm"},{"cmd":"yarn add normalize-pkg","lang":"bash","label":"yarn"},{"cmd":"pnpm add normalize-pkg","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core schema engine for field definitions and normalization","package":"map-schema","optional":false},{"reason":"Used to infer package name when missing","package":"project-name","optional":true}],"imports":[{"note":"The package exports a single function; default import is recommended for ESM. CJS require also works.","wrong":"const normalizePkg = require('normalize-pkg')","symbol":"default","correct":"import normalizePkg from 'normalize-pkg'"},{"note":"The constructor is the default export; named import is incorrect.","wrong":"const { NormalizePkg } = require('normalize-pkg')","symbol":"NormalizePkg","correct":"import NormalizePkg from 'normalize-pkg'"},{"note":"Options must be passed to the constructor; setting afterwards may not apply correctly.","wrong":"const pkg = new NormalizePkg(); pkg.options.knownOnly = true;","symbol":"NormalizePkg options","correct":"import NormalizePkg from 'normalize-pkg';\nconst pkg = new NormalizePkg({ knownOnly: true });"}],"quickstart":{"code":"import NormalizePkg from 'normalize-pkg';\nimport pkgJson from './package.json' assert { type: 'json' };\n\nconst normalizer = new NormalizePkg();\nconst normalized = normalizer.normalize(pkgJson);\nconsole.log(JSON.stringify(normalized, null, 2));","lang":"typescript","description":"Demonstrates importing normalize-pkg, creating an instance, and normalizing a package.json object. Note: uses import assertions for JSON modules."},"warnings":[{"fix":"Pass options to the constructor: new NormalizePkg({ knownOnly: true })","message":"Options like knownOnly must be passed to the constructor, not set after instantiation.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use structuredClone or Object.assign: normalizer.normalize({...pkg})","message":"The normalize() method mutates the input object; pass a copy if you need to preserve the original.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use npm only: npm install --save normalize-pkg","message":"Bower install instructions in README are outdated; Bower is deprecated.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Ensure process.cwd() contains the expected files or use options to disable filesystem checks.","message":"Some normalizers (e.g., bin) rely on the filesystem and may fail if the current working directory is not a package root.","severity":"gotcha","affected_versions":">=0.3.0"}],"env_vars":null,"search_vec":"'0.5.0':16 '2019':19 'accord':53 'approach':14 'author':31 'base':13 'bin':34 'build':64 'cli':60 'complet':50 'config':72 'configur':55 'consist':68 'field':28 'file':8 'filesystem':42 'fix':73 'infer':37 'javascript':71 'json':74,79 'last':17 'librari':4 'licens':32 'like':29 'mainten':24 'metadata':70 'miss':38 'mode':25 'need':67 'normal':2,6,75 'normalize-pkg':1 'object':52 'packag':69,76,78 'package-json':77 'package.json':7,51 'pkg':3,80 'process':65 'properti':81 'releas':18 'repositori':30 'rule':57 'scaffold':62 'schema':12,56 'schema-bas':11 'simpl':44 'stabl':21 'standard':27 'suitabl':58 'tool':46,61 'transform':48 'unlik':43 'use':9 'valid':45 'valu':39 'version':15","created_at":"2026-06-07T16:58:28.529323+00:00","updated_at":"2026-06-07T16:58:28.529323+00:00","problems":[{"fix":"Use import NormalizePkg from 'normalize-pkg' (default import)","cause":"Importing named export instead of default export","error":"TypeError: NormalizePkg is not a constructor"},{"fix":"Use new NormalizePkg() and then call .normalize()","cause":"Instantiating without new keywords or using an outdated API","error":"TypeError: config.normalize is not a function"},{"fix":"Install peer dependencies: npm install map-schema","cause":"Missing peer dependency when using npm < 7 or manually installed","error":"Error: Cannot find module 'map-schema'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/jonschlinkert/normalize-pkg","github":"https://github.com/jonschlinkert/normalize-pkg","docs":null,"changelog":null,"pypi":null,"npm":"normalize-pkg","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}