Publishing Scoped npm Packages with semantic-release
Configure semantic-release to publish scoped packages (@org/package) to npm with public access. Handle organization-scoped packages and custom registries.
Detailed Explanation
Scoped Package Publishing
Scoped npm packages (e.g., @myorg/my-package) require specific configuration to publish correctly, especially regarding access levels.
Configuration
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/npm", {
"npmPublish": true,
"pkgRoot": "."
}],
"@semantic-release/github"
]
}
package.json Requirements
Your package.json must include the publishConfig field for scoped packages:
{
"name": "@myorg/my-package",
"publishConfig": {
"access": "public"
}
}
Without "access": "public", npm defaults to restricted (private) for scoped packages, which requires a paid npm organization.
Custom Registry
To publish to a private registry (like GitHub Packages or Artifactory):
{
"name": "@myorg/my-package",
"publishConfig": {
"registry": "https://npm.pkg.github.com"
}
}
.npmrc Configuration
For CI environments, create an .npmrc file:
@myorg:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
Multiple Registries
To publish to both npm and GitHub Packages, use the exec plugin to run a second publish command after the npm plugin handles the primary registry.
Use Case
Organizations publishing scoped packages to npm, GitHub Packages, or private registries. Common for design system libraries, shared utility packages, and internal tooling published within an organization scope.
Try It — Semantic Release Config Builder
Related Topics
Basic npm Package Release with semantic-release
Basic Configuration
Monorepo semantic-release Configuration
Advanced Configuration
Prerelease Branch Configuration for semantic-release
Basic Configuration
semantic-release Without npm Publishing
Plugin Configuration
Custom Shell Commands with @semantic-release/exec
Plugin Configuration