NPM PUBLISH CONTENTS · RUNS IN YOUR BROWSER · NOTHING UPLOADED

Which files will npm publish put in my package?

Paste your package.json, the files in your package folder and your .npmignore or .gitignore. You get every file npm would ship, the rule that decides each one (file and line, or the folder npm never entered), and the things to fix before you publish: .env files and keys that would go public, a .gitignore that a .npmignore switched off, and entry points missing from the tarball.

Nothing you paste leaves this browser tab. The engine follows npm's own file-selection code and agrees with it on 3,000 random packages and 360 real ones (see the README).

1. Your package

One path per line, relative to the folder with package.json. find . -type f -not -path './.git/*' -not -path './node_modules/*' lists them all, including untracked and gitignored files, which npm can still publish. The output of npm pack --dry-run --json also works.

Each file under a ==> path <== line, which is what head -n 9999 .npmignore .gitignore lib/.npmignore prints. An ignore file in your list without contents here is read as empty.

From the command line

The same engine, no dependencies, no network: node cli.mjs . in a package folder prints what would ship and why; --why lib/a.js explains one path, --all lists what is left out, --verify runs your own npm pack --dry-run and says whether it agrees, and --fail-on high exits 1 so a CI job stops before a secret goes public. Source and README.

Questions

Why did npm publish a file that is in my .gitignore?

Because a .npmignore in the same folder replaces the .gitignore; npm reads one or the other, never both. The same happens at the package root when package.json has a files field: neither ignore file at the root is read. Copy the lines you still need into .npmignore, or list what should ship in files. The tool lists every file your .gitignore excludes that would now be published.

Which files does npm always include or always leave out?

Always included: package.json, and at the package root any README, LICENSE, LICENCE or COPYING file, plus the files named by main, browser and bin. Always left out: .git, the root node_modules, package-lock.json, yarn.lock, pnpm-lock.yaml and .npmrc, and by default .DS_Store, *.orig, npm-debug.log, editor swap files and the ignore files themselves. A node_modules folder below the root is not left out.

Why is my main file missing from the published package?

npm forces main into the package only when it is written without a leading ./ (for example dist/index.js, not ./dist/index.js). With the ./ the forcing rule never matches, so the file ships only if files or your ignore rules let it through. bin paths are cleaned first, so ./bin/cli.js works there. The tool reports both cases.

How do .npmignore patterns differ from .gitignore patterns?

npm matches with minimatch, not git's rules: case is ignored, a pattern without a slash matches the name at any depth, and leading and trailing spaces are trimmed. A rule like Docs also removes docs/ and lib/DOCS, even on a case-sensitive disk. The tool shows the file and line of the rule that decided each path.

How do I see what npm publish will upload before publishing?

Run npm pack --dry-run, which lists the files but not why. Paste that list, or your full file list, here to get the reason for each file, or run the command-line version in the package folder with --verify to compare its answer with npm pack's and --fail-on high to stop a CI job that would leak a secret.

Is anything I paste uploaded?

No. The engine runs in this browser tab. There are no accounts, cookies or analytics vendors, and the command-line version makes no network calls.