Commands for interacting with the npm registry to publish, search, and manage packages.
Publish packages to the npm registry and manage published versions.
/**
* Publish package to registry
* @param tarball-or-folder - Package tarball or directory (default: current directory)
* @param --tag - Tag for this version (default: 'latest')
* @param --access - Package access level ('public' or 'restricted')
* @param --dry-run - Show what would be published without publishing
* @param --otp - One-time password for 2FA
*/
npm publish [tarball|folder]
npm publish --tag beta
npm publish --access public
npm publish --dry-run
/**
* Remove package version from registry
* @param package - Package name with optional version
* @param --force - Skip confirmation prompt
* @param --otp - One-time password for 2FA
*/
npm unpublish <package>[@version]
npm unpublish <package>@<version> --force
/**
* Mark package as deprecated
* @param package - Package with optional version range
* @param message - Deprecation message
* @param --otp - One-time password for 2FA
*/
npm deprecate <package>[@version] <message>
/**
* Remove deprecation from package
* @param package - Package with optional version range
* @param --otp - One-time password for 2FA
*/
npm undeprecate <package>[@version]Usage Examples:
# Publish current directory
npm publish
# Publish with beta tag
npm publish --tag beta
# Publish scoped package as public
npm publish --access public
# Deprecate old version
npm deprecate my-package@"< 1.0.0" "This version has security vulnerabilities"
# Remove package completely
npm unpublish my-package --forceManage package versions and distribution tags.
/**
* Bump package version in package.json
* @param newversion - Version increment type or explicit version
* @param --preid - Prerelease identifier for prerelease versions
* @param --git-tag-version - Create git tag (default: true)
* @param --commit-hooks - Run git commit hooks (default: true)
*/
npm version <newversion>
npm version patch
npm version minor
npm version major
npm version prerelease
npm version 1.2.3
npm version prerelease --preid=beta
/**
* Manage distribution tags
* @param package - Package name
* @param version - Package version
* @param tag - Tag name
*/
npm dist-tag add <package>@<version> [tag]
npm dist-tag rm <package> <tag>
npm dist-tag ls [package]Usage Examples:
# Increment version
npm version patch # 1.0.0 -> 1.0.1
npm version minor # 1.0.1 -> 1.1.0
npm version major # 1.1.0 -> 2.0.0
# Prerelease versions
npm version prerelease --preid=alpha # 1.0.0 -> 1.0.1-alpha.0
# Manage distribution tags
npm dist-tag add my-package@1.0.1 latest
npm dist-tag add my-package@2.0.0-beta.1 beta
npm dist-tag ls my-packageSearch and view packages in the registry.
/**
* Search for packages in registry
* @param search-term - Search query
* @param --json - Output in JSON format
* @param --parseable - Output in parseable format
* @param --long - Show detailed package information
*/
npm search <search-term>
npm search express --json
npm search "test framework" --long
/**
* View package information
* @param package - Package name with optional version
* @param field - Specific field to display
* @param --json - Output in JSON format
*/
npm view <package>[@version] [field]
npm info <package>[@version] [field]
npm show <package>[@version] [field]
npm v <package>[@version] [field]Usage Examples:
# Search for packages
npm search express
npm search "css framework"
# View package information
npm view express
npm view express@latest
npm view express version
npm view express dependencies
npm view express repository.url
# View in JSON format
npm view express --jsonManage package ownership and access permissions.
/**
* Manage package access permissions
* @param subcommand - 'public', 'restricted', 'grant', 'revoke', 'ls-packages', 'ls-collaborators'
* @param package - Package name
* @param user - Username for grant/revoke operations
* @param permissions - Permission level ('read-only' or 'read-write')
*/
npm access public [package]
npm access restricted [package]
npm access grant <read-only|read-write> <user> [package]
npm access revoke <user> [package]
npm access ls-packages [user]
npm access ls-collaborators [package] [user]
/**
* Manage package ownership
* @param subcommand - 'add', 'rm', 'ls'
* @param user - Username
* @param package - Package name
*/
npm owner add <user> [package]
npm owner rm <user> [package]
npm owner ls [package]Usage Examples:
# Set package access
npm access public my-package
npm access restricted @myorg/private-package
# Grant access to users
npm access grant read-only username my-package
npm access grant read-write username my-package
# Manage ownership
npm owner add collaborator my-package
npm owner ls my-packageConfigure registry settings and authentication.
/**
* Set registry URL
* @param registry-url - NPM registry URL
* @param --scope - Apply to specific scope
*/
npm config set registry <registry-url>
npm config set @myorg:registry <registry-url>
/**
* User authentication
* @param --registry - Registry URL
* @param --scope - Scope for scoped login
*/
npm login [--registry=<registry-url>]
npm adduser [--registry=<registry-url>]
npm logout [--registry=<registry-url>]
/**
* Check current user
* @param --registry - Registry URL
*/
npm whoami [--registry=<registry-url>]Usage Examples:
# Set registry
npm config set registry https://registry.npmjs.org/
npm config set @mycompany:registry https://npm.mycompany.com/
# Authentication
npm login
npm login --registry=https://npm.mycompany.com/
npm whoami
npm logoutCommands for viewing and managing package metadata.
/**
* View package documentation
* @param package - Package name
*/
npm docs <package>
npm home <package>
/**
* View package repository
* @param package - Package name
*/
npm repo <package>
/**
* View package bugs/issues
* @param package - Package name
*/
npm bugs <package>
npm issues <package>
/**
* Star/unstar packages
* @param package - Package name
*/
npm star <package>
npm unstar <package>
npm stars [user]Usage Examples:
# Open package resources
npm docs express # Opens documentation
npm repo lodash # Opens repository
npm bugs jest # Opens issues page
# Package starring
npm star my-favorite-package
npm stars # List your starred packages
npm stars username # List user's starred packagesComplete workflow for publishing packages:
# 1. Prepare package
npm version patch
npm run build
npm run test
# 2. Review what will be published
npm publish --dry-run
# 3. Publish to registry
npm publish
# 4. Add distribution tags if needed
npm dist-tag add my-package@1.0.1 latestSetting up authentication for private registries:
# Login to default registry
npm login
# Login to private registry
npm login --registry=https://npm.mycompany.com/
# Set authentication token
npm config set //npm.mycompany.com/:_authToken <token>
# Verify authentication
npm whoami --registry=https://npm.mycompany.com/