A package can pass its repository tests and fail immediately after installation because its built entry point never entered the tarball. Test the archive a consumer will receive. Repository membership, package membership, and the public import interface are separate boundaries that need separate observations.
This exercise uses PowerShell, Node.js 24, and npm 11. It creates a synthetic package with no dependencies, packs it locally, and installs that archive in a disposable consumer. It performs no publication and requires no registry account. All files are harmless fixtures; do not use a real workspace containing private material for the exercise.
Declare the intended distribution boundary
The npm package.json reference describes the files allowlist and the interaction with ignore files. Some metadata files are included regardless of that list. Treat the resulting member list as authoritative evidence of what this invocation packed, rather than assuming a source-control ignore rule defines distribution.
An entry-point declaration does not build its target. A package that promises dist/index.js needs that file in the release tree before packing. This is especially easy to miss when repository tests import source files directly or a developer's working directory contains output from an earlier build.
Define the required files, the excluded classes of files, and the supported consumer import. Keep those checks distinct. A narrow archive can still omit a needed runtime asset, while a working import can coexist with unintended test data in the same archive.
Catch the missing output before packing the release
Start in a new empty parent directory. Create package-fixture, enter it, and save the following as package.json:
{
"name": "package-inspection-demo",
"version": "1.0.0",
"type": "module",
"main": "./dist/index.js",
"exports": "./dist/index.js",
"files": ["dist"]
}
Create one harmless source-tree note and preview the package:
Set-Content -LiteralPath internal-note.txt -Encoding ascii -Value 'Synthetic packaging fixture'
npm pack --dry-run --json --ignore-scripts
Inspect the files entries in the JSON result. dist/index.js is absent because it does not exist. The internal note should also be absent because it is outside the allowlist. A successful command therefore does not mean that the package's import contract is satisfied. This is the meaningful failure condition to enforce in a release gate.
The npm pack documentation describes the preview and JSON options. This exercise suppresses lifecycle scripts deliberately because it provides its built file explicitly. For a real package, run the reviewed build and preparation steps as explicit release inputs; suppressing them without replacement can create the very missing-output failure being tested.
Install the archive from a separate consumer
Create the declared output, then inspect and pack the corrected package:
New-Item -ItemType Directory -Path dist
Set-Content -LiteralPath dist/index.js -Encoding ascii -Value 'export const answer = 42;'
npm pack --dry-run --json --ignore-scripts
npm pack --json --ignore-scripts
Set-Location ..
New-Item -ItemType Directory -Path package-consumer
Set-Location package-consumer
npm init -y
npm install --offline --ignore-scripts --audit=false --fund=false ../package-fixture/package-inspection-demo-1.0.0.tgz
node --input-type=module -e "import { answer } from 'package-inspection-demo'; if (answer !== 42) throw new Error('Unexpected package result');"
The second preview should include the built entry and omit the internal note. The consumer import should finish successfully. Installing outside the source tree prevents a direct source import or a convenient local file from masking the distribution mistake.
The fixture's lack of dependencies makes the offline install self-contained. A real package may need a prepared dependency cache or an approved registry connection. Report a missing dependency as a separate failure; do not claim an archive was tested when installation never completed. Likewise, a consumer test should cover the declared module format and relevant asset paths, not only the existence of a package directory.
Extend the check with a package-specific negative assertion: an internal test fixture or source-only note should not be installed. Inspect only the synthetic test files you created. A package audit must not become an excuse to open credential-bearing files in the developer's workspace.
Keep the approved bytes tied to the release
Record the archive identity alongside the member list and consumer result. If the release process rebuilds or repacks later, repeat the checks for the new archive. The artifact promotion guide explains why testing one set of bytes does not validate a subsequent reconstruction.
Workspaces need an explicit package target. Running a command at a monorepo root can inspect a different package from the one intended for release. Confirm the name, version, and output filename from the pack result before associating it with an approval record. Treat required metadata and runtime files as assertions, not facts inferred from a familiar directory name.
After a failed preview, fix the packaging rule or build input and regenerate the archive. After a failed consumer test, keep the failure evidence and stop release approval. Do not repair only the consumer's installed copy, since that would leave the distributed archive unchanged.
Leave the disposable directories before removing them and confirm their paths. For the actual release, proceed only when the exact archive has the required members, excludes the defined private material, and passes its consumer contract. These checks establish packaging behavior; they do not prove the absence of vulnerabilities in the included code.
Was this guide useful?
Your rating helps us prioritize clearer, more practical technical content.
Review diffs, run checks, and prepare the release in Arezgit.
Keep Git review, security scanning, API checks, database inspection, and release preparation together in one local desktop application.
Explore Arezgit