Validate your package.json exports actually exist, have valid syntax, and can be imported or required without issues.
pnpm add validate-package-exports -Dnpm i validate-package-exports -Dyarn add validate-package-exports -D| Flag | Description | Default value |
|---|---|---|
--concurrency / -c |
How many tasks to do at the same time | availableParallelism() |
--dev-condition |
Specify which custom conditions are used only during development | none |
--bail / -b |
Stop processing at the first error. Enabled by default when CI=true |
process.env.CI === 'true' |
--no-bail |
Turn off --bail |
false |
--check / -s |
Check syntax of JS files | false |
--reporter |
Reporter to use for output | text |
--verbose |
Use verbose output | false |
--info / -i |
Show info messages.Enabled by default when RUNNER_DEBUG=1 |
process.env.RUNNER_DEBUG === '1' |
--no-info |
Turn off --info |
false |
--version / -v |
Print the version number | false |
--help / -h |
Show the help screen | false |
| Reporter | Description |
|---|---|
text |
Human-readable output with icons and colors. This is the default. |
json |
A single JSON array containing all results. |
ndjson |
Newline-delimited JSON. Each result is written as its own JSON object as soon as it's available. |
sarif |
SARIF 2.1.0 output, useful for integrating with tools like GitHub code scanning. |
validate-package-exports [FILE]... [options]ℹ️ If you do not provide a path to a package.json, it will try to find one in the current directory.
You can pipe in the list of packages to validate.
pnpm ls -r --depth -1 --parseable | pnpm dlx validate-package-exports --info{
"scripts": {
"build": "YOUR-BUILD-SCRIPT",
"postbuild": "validate-package-exports --check"
}
}OR
{
"scripts": {
"prepublishOnly": "validate-package-exports --check"
}
}If you use a customCondition in your tsconfig.json, like when using Nx, you can use the --dev-condition flag so that those entry points are skipped when validating which files are packed.
{
"scripts": {
"prepublishOnly": "validate-package-exports --check --info --dev-condition @example/monorepo"
}
}npx --yes validate-package-exports ./path/to/package.json --checkfnm use
corepack enable
pnpm install
pnpm build
Run in separate tabs.
pnpm build -w./dist/cli.mjs [FILE]... [OPTIONS]This example demonstrates how you can bulk validate packages by piping in the package.json paths (one per line).
find -L ./node_modules -type d -name '.*' -prune -o \
-type f -regex '.*/node_modules/\(@[^/]+/\)?[^/]+/package\.json' -print | ./dist/cli.mjs