snpmv2026.1.7

CLI Reference

Complete command-line reference for snpm

Complete reference for all snpm commands and options.

Global Flags

These flags can be used with any command:

  • -v, --verbose - Enable verbose logging output

Example:

snpm install --verbose
snpm add react --verbose

Commands

install

snpm install [packages...]

Install dependencies from package.json or add specific packages.

Options:

  • --production - Skip dev dependencies
  • --frozen-lockfile, --immutable - Fail if lockfile needs updates
  • -f, --force - Force re-download all packages
  • -w, --workspace <name> - Target specific workspace project

add

snpm add <packages...>

Add packages to dependencies.

Options:

  • -D, --dev - Add as dev dependency
  • -g, --global - Install globally
  • -f, --force - Force re-download
  • -w, --workspace <name> - Target specific workspace project

remove

snpm remove <packages...>

Remove packages from the project.

run

snpm run <script> [-- <args>]

Run a script from package.json.

Options:

  • -r, --recursive - Run in all workspace projects
  • --filter <pattern> - Run in filtered workspace projects (supports globs)
  • --skip-install - Skip automatic install check

upgrade

snpm upgrade [packages...]

Update packages to their latest versions within semver constraints.

Options:

  • --production - Only upgrade production dependencies
  • -f, --force - Force re-download

outdated

snpm outdated

Check for outdated packages.

Options:

  • --production - Only check production dependencies

dlx

snpm dlx <package> [args...]

Download and execute a package binary. Alias: spx.

exec

snpm exec <command> [args...]

Execute a command with node_modules/.bin in PATH.

Options:

  • -c, --shell-mode - Run through shell (pipes, redirects)
  • -r, --recursive - Run in all workspace projects
  • --filter <pattern> - Filter workspace projects
  • --skip-install - Skip automatic install check

list

snpm list

List installed packages.

Options:

  • -g, --global - List globally installed packages

patch

snpm patch <subcommand>

Modify installed packages. Subcommands: edit, commit, remove, list.

clean

snpm clean

Remove cached packages and metadata.

Options:

  • -y, --yes - Skip confirmation
  • --dry-run - Preview without deleting
  • --packages - Only clean packages
  • --metadata - Only clean metadata
  • --global - Also clean global installs
  • --all - Clean everything

init

snpm init

Initialize a new package.json.

login

snpm login

Authenticate with an npm registry.

Supports both Bearer and Basic authentication schemes:

  • Bearer: use an auth token via --token or environment variables
  • Basic: typically provided via web-based login (--web) where username/password are exchanged for a session token

Options:

  • --registry <url> - Registry URL (scheme required, e.g. https://; trailing slashes are normalized)
  • --token <token> - Auth token (Bearer scheme)
  • --scope <scope> - Associate scope with registry
  • --web - Use web-based authentication (Basic credentials exchanged for a token)

logout

snpm logout

Remove registry credentials.

Options:

  • --registry <url> - Registry URL
  • --scope <scope> - Remove credentials for specific scope

config

snpm config

Show the resolved configuration and runtime paths.

Environment Variables

VariableDescription
SNPM_HOMECustom home directory for cache and data
SNPM_REGISTRYDefault registry URL
NPM_CONFIG_REGISTRY, npm_config_registryAlternative registry URL (npm compatibility)
SNPM_MIN_PACKAGE_AGE_DAYSMinimum package age in days
SNPM_MIN_PACKAGE_CACHE_AGE_DAYSMetadata cache age in days
SNPM_HOISTHoisting mode: none, single-version, all
SNPM_LINK_BACKENDLink strategy: auto, hardlink, symlink, copy
SNPM_STRICT_PEERSFail on peer dependency conflicts
SNPM_FROZEN_LOCKFILEDefault frozen lockfile mode
SNPM_REGISTRY_CONCURRENCYMax concurrent registry requests
SNPM_ALLOW_SCRIPTSComma-separated list of packages allowed to run install scripts
SNPM_VERBOSEEnable verbose logging
SNPM_LOG_FILECustom log file path
NPM_TOKEN, SNPM_AUTH_TOKEN, NODE_AUTH_TOKENRegistry authentication token (Bearer)

Examples

Basic Usage

# Install dependencies
snpm install

# Add packages
snpm add react react-dom
snpm add -D typescript

# Remove packages
snpm remove lodash

# Run scripts
snpm run build
snpm run test -- --watch

# Upgrade packages
snpm upgrade
snpm upgrade react

# Check for updates
snpm outdated

Workspaces

# Install all workspace packages
snpm install

# Install in specific workspace
snpm install -w ui

# Add to specific workspace
snpm add react -w ui

# Run in all workspaces
snpm run build --recursive

# Run in filtered workspaces
snpm run test --filter "ui"
snpm run build --filter "app-*"

CI/CD

# Frozen lockfile (fail if out of sync)
snpm install --frozen-lockfile

# Production install
snpm install --production --frozen-lockfile

# With security settings
SNPM_MIN_PACKAGE_AGE_DAYS=7 snpm install --frozen-lockfile

Authentication

# Login to default registry
snpm login

# Login with token (Bearer)
snpm login --token npm_xxxxxxxxxxxxx

# Login to private registry (URL must include protocol)
snpm login --registry https://npm.mycompany.com

# Login with scope
snpm login --scope @myorg --registry https://npm.mycompany.com

# Web-based login (Basic credentials exchanged for token)
snpm login --web

# Logout
snpm logout

Exit Codes

CodeMeaning
0Success
1Error

Comparison with npm

npmsnpm
npm installsnpm install
npm install <pkg>snpm add <pkg>
npm uninstall <pkg>snpm remove <pkg>
npm updatesnpm upgrade
npm outdatedsnpm outdated
npm run <script>snpm run <script>
npm initsnpm init
npm loginsnpm login
npm logoutsnpm logout

On this page