npm-publish
Original:🇺🇸 English
Translated
Guide for publishing packages to the npm registry. Use this skill when the user wants to publish a new package, release a new version, or manage npm package configurations.
4installs
Added on
NPX Install
npx skill4agent add toilahuongg/shopify-agents-kit npm-publishTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →npm Publish Guide
This skill guides you through the process of publishing a package to the npm registry.
1. Prerequisites
Before publishing, ensure you are logged in to npm.
bash
npm whoamiIf not logged in:
bash
npm login2. Preparation & Configuration
Critical package.json
Fields
package.jsonEnsure these fields are correct:
- name: Unique package name (scoped names like are recommended for organizations).
@org/pkg - version: SemVer compliant version (e.g., ).
1.0.0 - main/module/exports: Entry points for your library.
- files: Whitelist of files to include (reduces package size).
- private: Must be (or missing) to publish.
false
Excluding Files
Use a file or the array in to prevent publishing unnecessary files (tests, src, config files).
Tip: shows exactly what will be packed.
.npmignorefilespackage.jsonnpm publish --dry-runBuild (If applicable)
If your package requires compilation (TypeScript, Babel, etc.), run the build script first.
bash
npm run build3. Versioning
Update the package version before publishing. This command increments the version in and creates a git tag.
package.jsonbash
# Choose one:
npm version patch # 1.0.0 -> 1.0.1
npm version minor # 1.0.0 -> 1.1.0
npm version major # 1.0.0 -> 2.0.04. Publishing
Dry Run
Always do a dry run first to verify contents.
bash
npm publish --dry-runScoped Packages
If publishing a scoped package (e.g., ) publicly for the first time:
@myorg/my-pkgbash
npm publish --access publicStandard Publish
bash
npm publish5. Post-Publish
Push Tags
Push the new version commit and tags to your git repository.
bash
git push --follow-tagsVerification
Check the npm registry or install the package in a test project to verify.
bash
npm view <package-name> version