A CLI to lint a lockfile for security policies
npx @tessl/cli install tessl/npm-lockfile-lint@4.14.1lockfile-lint is a CLI tool for linting npm and yarn lockfiles to enforce security policies and prevent malicious package injection attacks.
npm install lockfile-lintExecution Model:
0 on success (no issues), 1 on failure (issues detected or errors)Required Arguments:
--path or -p: Path to lockfile (required) - can be a single file or glob patternKey Validation Capabilities:
Default Behaviors:
--type not specified--empty-hostname true)Execution Lifecycle:
When to Use:
Decision Points for Agents:
--validate-https for strict HTTPS-only (mutually exclusive with --allowed-schemes)--allowed-schemes when git-based dependencies are needed (e.g., git+https:)--allowed-hosts when using --validate-package-names--format plain in non-interactive environments (CI/CD)--type explicitly for non-standard lockfile filenames"packages/**/package-lock.json"# Install
npm install lockfile-lint
# Basic usage - validate HTTPS
lockfile-lint --path package-lock.json --validate-https
# Validate with allowed hosts
lockfile-lint --path package-lock.json --allowed-hosts npm --validate-https
# Use via npx (no installation)
npx lockfile-lint --path package-lock.json --validate-https --allowed-hosts npm --format plainSee Quick Start Guide for detailed setup instructions.
git+https:)Configuration can be provided via:
See Configuration Reference for details.
0: Success - no security issues detected1: Failure - violations found, errors, or missing argumentsReal-World Scenarios - Comprehensive usage examples
Edge Cases - Advanced scenarios and corner cases
CLI Options - Complete command-line interface reference
Configuration - Configuration file reference
Integration Patterns - Integration examples
Error Handling - Troubleshooting guide
Programmatic Usage: lockfile-lint is CLI-only and does not export a programmatic API. For programmatic access, consider using the underlying lockfile parsing libraries directly.
Non-Interactive Environments: Use --format plain in CI/CD pipelines for better log parsing and to avoid ANSI color codes.
Performance: Validation of large lockfiles (thousands of packages) may take several seconds. Consider caching results in CI/CD.
Lockfile Updates: Re-run validation after npm install or yarn install to catch new violations.
Security Best Practices: Always use --validate-https and --allowed-hosts together for maximum security. Combine with --validate-integrity for complete protection.
Agent Usage Patterns:
0 = success, 1 = failure--format plain for programmatic output parsingDEBUG=lockfile-lint for troubleshooting