Registry / devops / publint

publint

JSON →
library0.3.18jsnpmunverified

publint is a tool for linting npm packaging errors to ensure compatibility across environments. The current stable version is 0.3.18, with frequent patch releases addressing edge cases in export mapping, file existence checks, and CJS/ESM interop warnings. It differentiates from tsc or api-extractor by focusing specifically on package.json validation, including exports, imports, main, types fields, and CommonJS default export issues. It provides a CLI, API, and online playground, and supports Node >=18.

npm install publint
INSTALL
IMPORT
SIG · PUBLINT
P
publint
devopsjavascriptv0.3.18
harness data pending
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.

publint
import { publint } from 'publint'
import publint from 'publint'
publint is a named export, not default.
check
import { check } from 'publint'
const check = require('publint').check
ESM-only since v0.3.0; CommonJS require may fail.
getPkgPathValue
import { getPkgPathValue } from 'publint/utils'
import { getPkgPathValue } from 'publint'
Utility functions are in 'publint/utils' subpath.

Demonstrates using the publint API to lint a package.json and print formatted messages.

import { check, formatMessage } from 'publint'; import { readFile } from 'node:fs/promises'; const pkgJson = JSON.parse(await readFile('./package.json', 'utf-8')); const results = await check({ pkg: pkgJson, rootDir: '.' }); for (const msg of results.messages) { console.log(formatMessage(msg)); }
publint --version
Debug
Known issues
breakingRequires Node >=18; older versions will fail
fix
Upgrade Node to >=18.
affects: <18
breakingESM-only since v0.3.0; CommonJS require will not work
fix
Use import statements instead of require().
affects: >=0.3.0
deprecatedSome rules may change severity in future; check docs
fix
Stay updated via changelog.
affects: all
Errors
Common errors & fixes
SyntaxError: Unexpected token '?'
Using Node <18 which lacks support for ?? operator in publint code
fix
Upgrade Node to 18 or later.
ERR_MODULE_NOT_FOUND: Cannot find module 'publint'
Using CommonJS require() with ESM-only package
fix
Add "type": "module" in package.json and use import statements.
Error: Cannot find module 'publint/utils'
Incorrect import path; utility exports are under 'publint/utils' subpath
fix
Import from 'publint/utils' instead of 'publint'.
Upgrade
Version history
0.3.18latest on npm
Audit
Dependencies
publintrequiredCLI/API tool; no required peer dependencies
@publint/packoptionalUsed internally for packing packages; installed automatically
Agent activity
6 hits · last 30 days
node
6
Resources
publint — npm install publint · libregistry