Publishing to npm
When a package.json exists in the project root, @neosjs/release automatically enables the built-in npm plugin, which reads and bumps the version field in package.json and, when publishing is enabled, publishes the package to the npm registry.
Note the default: unlike
release-it,npm.publishin@neosjs/releasedefaults tofalse(the version number is bumped but the package is not published). To publish to npm, setnpm.publish: trueexplicitly in your configuration file or pass--npm.publishon the command line.
- To skip only the publish step but still update the version in
package.json: keep the defaultnpm.publish: false(or set"private": trueinpackage.json). - To neither read nor modify
package.json, and not publish: use--no-npmor configurenpm: false.
Pre-publish Checks and Automatic Login
When npm.publish: true, the package is not private (private !== true), and npm.skipChecks: true is not set, the following checks run in parallel during the init stage (default timeout 10 seconds, controlled by npm.timeout):
- Registry connectivity check:
npm ping - Authentication check:
npm whoami - Collaborator permission check:
npm access list collaborators --json <pkg>(npm access ls-collaboratorson npm <= 9), verifying that the current user haswriteaccess - Published version check:
npm show <pkg>@<tag> version; a warning is printed if the version has not been published yet or differs from the localpackage.json
Automatic Login in Interactive Mode
If you are not logged in (error code ENEEDAUTH or E401) in interactive mode (not --ci, not --dry-run, and stdin is a TTY), @neosjs/release automatically inherits the terminal and runs npm login; once login completes, it re-checks authentication and continues the release.
Automatic login happens during the
initstage, and thebefore:inithook runs before login. For that reason, it is recommended to put time-consuming checks such aslintandtestinafter:init.
Private Registry Compatibility
publishConfig.registryinpackage.json(and any configuration key ending inregistry) is automatically read as the target registry and passed along with the--registryargument.publishConfig.publicPathlets you customize the URL path of the package page printed after a successful publish (default/package).- Some private registries (such as Nexus and Verdaccio) do not support
npm ping,npm whoami, ornpm access: onE400/E404responses, the tool prints a warning and continues; you can also setnpm.skipChecks: trueto skip all checks.
Pre-release Safety Checks
@neosjs/release ships with two safety checks that work out of the box. They are enabled by default and print warnings; setting npm.strictChecks to true turns the warnings into blocking errors (npm.skipChecks: true skips these checks as well).
1. Potential Breaking Change Detection (npm.checkBreakingChanges)
During the beforeBump stage, when the target version does not reach the breaking level (1.x+ without a major bump, or 0.x without a minor/major bump), the current package.json is compared with the one at the previous tag (<latestTag>:package.json) to automatically detect the following risks:
- An
engines.noderestriction was added, or the minimumengines.nodeversion was raised - The
typefield changed (commonjs↔module) - An existing entry field was removed:
main,module,types,typings - An existing
binCLI command was removed - The
exportsfield was added or removed, an existingexportssubpath was removed, or the CommonJS (require) condition entry inexportswas removed
(--canary mode and --no-increment mode skip this check automatically.)
2. Package Contents Scan (npm.checkFiles)
Before running publish, npm pack <publishPath> --dry-run --json is run automatically to print the number of files about to be published along with the packed and unpacked sizes, and to scan for two kinds of suspicious files:
- Potentially sensitive files:
.env/.env.*(.env.example/.sample/.template/.distare allowed automatically),.npmrc,.pypirc,.netrc,id_rsa*,id_ed25519*,credentials.*,secret*/secrets.*,*.pem,*.key,*.p12,*.pfx. - Potentially development/test files:
.git/,.github/,.vscode/,.idea/,coverage/,.nyc_output/, top-leveltest//tests//__tests__//__mocks__//__fixtures__//e2e/,.DS_Store,Thumbs.db,*.test.*,*.spec.*.
Example of enabling strict mode:
export default {
npm: {
publish: true,
checkFiles: true,
checkBreakingChanges: true,
strictChecks: true
}
}dist-tag Resolution Rules (npm.tag)
When npm.tag is not set manually, the tool decides the publish tag automatically in the following order of priority:
- Stable versions: always
latest. - Pre-release versions:
- The string pre-release identifier is extracted from the version number first (for example
2.0.0-beta.1→beta,1.0.0-rc.0→rc). - If the pre-release segment of the version is purely numeric and cannot be inferred (for example
1.0.1-0), and a publish will actually run this time, the npm registry'sdist-tagsare queried: a non-latesttag that already points to the current version is reused first, otherwise the first existing non-latesttag is used; if the registry has no pre-release tags yet,nextis used by default.
- The string pre-release identifier is extracted from the version number first (for example
--canarymode: set automatically to the identifier passed to--canary(defaultcanary), so nothing is published tolatestby mistake.
Publishing with pnpm or bun
npm.publishPackageManager specifies the package manager used to publish. It supports 'npm' (default), 'pnpm', or 'bun':
{
"npm": {
"publish": true,
"publishPackageManager": "pnpm",
"publishArgs": ["--no-git-checks"]
}
}About
--no-git-checkswith pnpm: thenpmplugin runs before thegitplugin during thereleasestage, whenpackage.jsonandCHANGELOG.mdhave been modified but not yet committed. pnpm's default Git status check refuses to publish withERR_PNPM_GIT_UNCLEAN, so--no-git-checksmust be passed inpublishArgs.
npm.publishPackageManageronly affects thepublish(andstage publish) command; the version bump (npm version) and the pre-checks still run throughnpm.
Two-Factor Authentication (2FA)
- One-time password (TOTP):
- In interactive mode, if npm returns an error requiring an OTP, you are prompted to enter the one-time password and the publish is retried automatically.
- You can also provide it directly on the command line:
release --npm.otp=123456.
- Security keys / Passkeys (WebAuthn):
- In interactive mode (including
--only-version) and when not innpm.stagemode, thepublishcommand inherits the current terminal's stdin/stdout so that npm can open the browser authorization link directly or wait for the hardware key confirmation. - CI mode (
--ci) does not inherit the terminal.
- In interactive mode (including
Staged Publishing
With npm.stage: true enabled, the tool runs npm stage publish (or pnpm stage publish) and submits the package to npm's staging queue:
- No 2FA is required at submission time, which makes it ideal for building and submitting packages automatically in CI/CD pipelines.
- It requires npm >= 11.15.0 or pnpm >= 11.3.0 (the version is verified automatically during initialization; if the requirement is not met, the tool fails early).
- After the submission completes, the tool prints the URL of the staging approval page along with the matching approval command:
npm stage list # List staged publishes
npm stage approve <stage-id> # A maintainer completes 2FA approval and publishesA successful staged submission does not mark
isReleasedas officially released (because it has not been approved and published yet).
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
npm.publish | boolean | false | Whether to publish the package to the npm registry |
npm.publishPath | string | '.' | Directory to publish (for example 'dist') |
npm.publishArgs | string[] | string | [] | Extra arguments passed to the publish command (for example ['--access', 'public'], ['--provenance']) |
npm.publishPackageManager | 'npm' | 'pnpm' | 'bun' | 'npm' | Package manager used to publish |
npm.stage | boolean | false | Enable npm staged publishing (stage publish) |
npm.tag | string | null | null | Manually specify the dist-tag to publish to |
npm.otp | string | null | null | One-time password (TOTP) |
npm.ignoreVersion | boolean | false | When true, the version in package.json is ignored and the current version is determined by Git tags or other plugins instead |
npm.allowSameVersion | boolean | false | Allow the new version to be the same as the current package.json version (--allow-same-version) |
npm.versionArgs | string[] | string | [] | Extra arguments passed to npm version |
npm.skipChecks | boolean | false | Skip the registry connectivity, authentication, and collaborator checks as well as the checkFiles / checkBreakingChanges checks |
npm.checkFiles | boolean | true | Run npm pack --dry-run --json before publishing to scan for potentially sensitive or development/test files |
npm.checkBreakingChanges | boolean | true | Compare against the package.json at the previous tag to detect potential breaking changes |
npm.strictChecks | boolean | false | When true, turns the checkFiles and checkBreakingChanges warnings into blocking errors |
npm.timeout | number | 10 | Timeout of the npm registry pre-checks (in seconds) |
Complete Default Configuration
{
npm: {
publish: false,
publishPath: '.',
publishArgs: [],
publishPackageManager: 'npm',
tag: null,
stage: false,
otp: null,
ignoreVersion: false,
allowSameVersion: false,
versionArgs: [],
skipChecks: false,
checkFiles: true,
checkBreakingChanges: true,
strictChecks: false,
timeout: 10
}
}