Skip to main content

npm/pnpm/yarn

Publish packages to npm registry using Universal Release.

Detection​

Automatically detected when package.json exists.

Configuration​

ecosystems:
npm:
enabled: true
registry: https://registry.npmjs.org
validation:
build: true
test: true
lint: true
prePublishScripts:
- bun audit
tag: latest

Credentials​

Store your npm token securely:

release secrets set NPM_TOKEN

Get your token from npmjs.com.

Publishing​

# Publish with validation
release publish --ecosystem npm

# Dry run
release publish --ecosystem npm --dry-run

# Publish with specific tag
release publish --ecosystem npm --tag beta

Version Management​

# Show current version
release version

# Bump version
release version --bump patch

# Set specific version
release version --set 2.0.0

Validation​

Universal Release validates:

  • βœ… package.json exists and is valid
  • βœ… Build succeeds (bun run build)
  • βœ… Tests pass (bun test)
  • βœ… Linting passes (bun run lint)
  • βœ… No uncommitted changes

Rollback​

npm supports deprecation:

release rollback 1.2.3 --strategy deprecate

This runs npm deprecate package@1.2.3 "Rolled back due to issues".

Best Practices​

Use .npmignore​

# .npmignore
src/
tests/
*.test.ts
.github/

Configure package.json​

{
"files": ["dist"],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "bun build src/index.ts --outdir dist",
"test": "bun test",
"prepublishOnly": "bun run build"
}
}

Bun Native Publishing​

Universal Release uses bun publish which is faster than npm publish:

// Internally uses:
await $`bun publish --access public`.cwd(packagePath);

Next Steps​