Publish Packages to npm Registry
Prepare, version, and publish npm packages to the public registry with proper metadata, access controls, and automated release workflows.
Prerequisites
- -npm account created at npmjs.com
- -npm CLI authenticated with 'npm login'
Steps
Prepare package.json metadata
Ensure your package has the required fields for publishing.
The 'files' field acts as a whitelist for published files. Only include dist/ to keep the package size small.
Preview what will be published
Check exactly which files will be included in the package tarball.
Build and verify the package
Compile the package and run tests before publishing.
Always run your full test suite before publishing. A broken published version cannot be easily unpublished after 72 hours.
Publish the package
Push the package to the npm registry.
Scoped packages (@org/pkg) are private by default. Use --access public for open-source packages.
Verify the published package
Confirm the package is live on the registry.
Full Script
FAQ
Discussion
Loading comments...