{"id":26019,"library":"npm-package-json-lint","title":"npm-package-json-lint","description":"Configurable linter for package.json files. Version 10.3.0 requires Node >=22 and npm >=10. Enforces standards like valid data types, lowercase names, valid semver, presence of required fields, and dependency correctness. Ships TypeScript types and supports both CLI and programmatic usage with flat config (ESLint-style) since v10.0.0. Frequent releases; actively maintained.","status":"active","version":"10.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/tclindner/npm-package-json-lint","tags":["javascript","lint","linter","package.json","audit","auditor","npm-package-json-lint","typescript"],"install":[{"cmd":"npm install npm-package-json-lint","lang":"bash","label":"npm"},{"cmd":"yarn add npm-package-json-lint","lang":"bash","label":"yarn"},{"cmd":"pnpm add npm-package-json-lint","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Configuration loading","package":"cosmiconfig","optional":false},{"reason":"Ignore file support","package":"ignore","optional":false},{"reason":"Semver validation","package":"semver","optional":false}],"imports":[{"note":"ESM-only since v10.0.0. Use named import.","wrong":"const Linter = require('npm-package-json-lint')","symbol":"Linter","correct":"import { Linter } from 'npm-package-json-lint'"},{"note":"Named export. CommonJS require will not work directly.","wrong":"const lintFiles = require('npm-package-json-lint').lintFiles","symbol":"lintFiles","correct":"import { lintFiles } from 'npm-package-json-lint'"},{"note":"TypeScript type export for configuration objects.","wrong":"","symbol":"NpmPackageJsonLintConfig","correct":"import type { NpmPackageJsonLintConfig } from 'npm-package-json-lint'"}],"quickstart":{"code":"import { Linter } from 'npm-package-json-lint';\n\nconst linter = new Linter({\n  rules: {\n    'require-name': 'error',\n    'require-version': 'error',\n    'valid-values-name-scope': ['error', ['@myorg']],\n    'prefer-absolute-version-dependencies': 'error',\n  },\n});\n\nconst results = linter.lintFiles(['package.json']);\n\nif (results.results[0].issues.length > 0) {\n  console.log('Issues found:', JSON.stringify(results.results[0].issues, null, 2));\n} else {\n  console.log('No issues found.');\n}","lang":"typescript","description":"Programmatic usage: instantiate Linter with rules, lint package.json, and log issues."},"warnings":[{"fix":"Upgrade Node.js to version 22 or higher.","message":"Dropped support for Node.js 20 in v10.0.0; requires Node >=22.","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"Use ESM imports and flat config format. See migration guide.","message":"v10.0.0 switched from CommonJS to ESM and introduced flat config (ESLint-style).","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"Upgrade Node.js to version 20 or higher (or 22 for v10+).","message":"Dropped support for Node.js 18 in v9.0.0.","severity":"breaking","affected_versions":">=9.0.0"},{"fix":"Upgrade Node.js to version 18 or higher.","message":"Dropped support for Node.js 16 in v8.0.0.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"Use 'prefer-alphabetical' rule instead.","message":"The 'prefer-alphabetical-dependencies' rule is deprecated in favor of 'prefer-alphabetical'.","severity":"deprecated","affected_versions":">=7.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use ESM import: import { Linter } from 'npm-package-json-lint';","cause":"Missing or incorrect import/require statement when using CommonJS after v10.0.0.","error":"Error: Cannot find module 'npm-package-json-lint'"},{"fix":"Use named imports: import { lintFiles } from 'npm-package-json-lint';","cause":"Using the old CommonJS require pattern that returns an object exported via module.exports after v10.0.0.","error":"npmPackageJsonLint is not a function"},{"fix":"Import Linter as a named export: import { Linter } from 'npm-package-json-lint';","cause":"Importing Linter incorrectly (e.g., default import) when it's a named export.","error":"TypeError: Linter is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}