Before You Run npm publish: An Eighteen-Item Checklist

Publishing to npm is a single command, which is exactly why it goes wrong. A version, once published, can only be unpublished under the registry's restrictive policy, so the time to catch a mistake is before the command, not after. Work through these items in order; each has one line saying why it is on the list.

Metadata in package.json

Tarball contents

Entry points and types

npm pack
mkdir /tmp/try && cd /tmp/try && npm init -y
npm install /path/to/package-a-1.2.0.tgz
node -e "import('package-a').then(m => console.log(Object.keys(m)))"

Quality gates and the publish itself

After publishing

Check the package page on the registry, then install the new version by name from a clean directory. If something is wrong, publishing a fixed patch is usually better than unpublishing; npm Docs describe the current unpublish rules, and the notes on npm's unpublish policy explain the background. Related reading: setting up the exports field, pre-release versions and dist-tags and the npm provenance explainer.