lockfile-lint --path <lockfile> [options]Executable: lockfile-lint
--path, -p (string)Path to lockfile or glob pattern for multiple lockfiles.
package-lock.json, yarn.lock, packages/**/package-lock.json--type, -t (string)Lockfile type - "npm" or "yarn" (auto-detected if omitted).
package-lock.json or npm-shrinkwrap.json → npm, yarn.lock → yarn--help, -h (boolean)Display help text with all available options.
--version (boolean)Display version number.
--validate-https, -s (boolean)Validates all package URLs use HTTPS protocol.
https:// schemehttp:// or other non-HTTPS schemes--allowed-schemes--allowed-hosts, -a (array)Whitelist of allowed registry hosts.
--allowed-hosts npm yarn github.comnpm, yarn, verdaccio (see Host Aliases below)--validate-package-names--allowed-schemes, -o (array)Whitelist of allowed URI schemes.
--allowed-schemes "https:" "git+https:"--validate-https (cannot use both)https:, git+https:, git+ssh:, file:--allowed-urls, -u (array)Whitelist of specific allowed URLs.
--allowed-urls "https://github.com/user/repo#commit-hash"--allowed-hosts, URL validation is optimized through host validation--validate-package-names, -n (boolean)Validates package name matches resolved URL.
--allowed-hosts to be specified--allowed-package-name-aliases for legitimate aliases--validate-integrity, -i (boolean)Validates integrity hashes use sha512 algorithm.
--integrity-exclude--allowed-package-name-aliases, -l (array)Allows package name aliases in format "name:alias".
--allowed-package-name-aliases "string-width-cjs:string-width"name is the package.json name, alias is the resolved name--validate-package-names is enabled"package-name:resolved-name"--integrity-exclude (array)Excludes specific packages from integrity validation.
--integrity-exclude "legacy-package" "another-package"--empty-hostname, -e (boolean, default: true)Allows empty hostnames in URLs.
true: Allows URLs with empty hostnames (e.g., file:///path/to/package)false: Rejects URLs with empty hostnamestrue for compatibility with local file-based packagesfalse to reject local file dependencies--format, -f (string)Output format - "pretty" (default, with colors) or "plain" (no colors).
package-lock.json, npm-shrinkwrap.jsonyarn.lock--type not specifiedThe --allowed-hosts option supports convenient aliases:
npm → https://registry.npmjs.orgyarn → https://registry.yarnpkg.comverdaccio → https://registry.verdaccio.orgThese aliases can be used instead of full registry URLs for convenience.
0: Success - no security issues detected, validation passed1: Failure - occurs when:
--path specified)--allowed-schemes and --validate-https are mutually exclusive (cannot use both)
--validate-https for strict HTTPS-only validation--allowed-schemes when you need to allow specific non-HTTPS schemes (e.g., git+https:)--validate-package-names requires --allowed-hosts to be specified
--allowed-urls and --allowed-hosts are provided, URL validation is optimized through host validation
HTTPS Validation: Checks that all resolved package URLs use https:// protocol. Fails on http://, file://, or any other scheme unless explicitly allowed.
Host Validation: Extracts hostname from each package URL and verifies it matches one of the allowed hosts. Supports host aliases and exact hostname matching.
Scheme Validation: Validates that URL scheme matches one of the allowed schemes. Case-insensitive matching. Common schemes: https:, git+https:, git+ssh:, file:.
Package Name Validation: Compares package name from package.json with the resolved package URL. Ensures the package name matches the URL path to prevent aliasing attacks.
Integrity Validation: Verifies that all packages have integrity hashes and that they use sha512 algorithm. Checks for presence of integrity field and validates algorithm.
URL Validation: When --allowed-urls is specified, validates that package URLs exactly match one of the allowed URLs (including path and fragment).
# Validate HTTPS only
lockfile-lint --path yarn.lock --validate-https
# Validate specific hosts with HTTPS
lockfile-lint --path package-lock.json --allowed-hosts npm --validate-https
# Allow GitHub packages with git+https scheme
lockfile-lint --path yarn.lock --allowed-hosts yarn github.com --allowed-schemes "https:" "git+https:"
# Multiple lockfiles via glob pattern
lockfile-lint --path "packages/**/package-lock.json" --validate-https --allowed-hosts npm
# Allow specific URL with host validation
lockfile-lint --path yarn.lock --allowed-hosts yarn --allowed-urls "https://github.com/user/repo#commit-hash"
# Validate package names match URLs
lockfile-lint --path package-lock.json --allowed-hosts npm --validate-package-names
# Validate integrity hashes
lockfile-lint --path package-lock.json --validate-integrity
# Validate integrity with exclusions
lockfile-lint --path yarn.lock --validate-integrity --integrity-exclude "legacy-package" "another-package"
# Allow package aliases
lockfile-lint --path package-lock.json --allowed-hosts npm --validate-package-names --allowed-package-name-aliases "string-width-cjs:string-width"
# Plain output for CI/CD
lockfile-lint --path package-lock.json --validate-https --allowed-hosts npm --format plain
# Explicit lockfile type
lockfile-lint --path custom.lock --type npm --validate-https
# Debug mode
DEBUG=lockfile-lint lockfile-lint --path yarn.lock --validate-https