audit Verified current stable Not installed? Package Management

Audit / Exclude Optional Dependencies Audit

Exclude Optional Dependencies Audit

Conducts a security audit while excluding optional dependencies in a PNPM project.

$
Terminal
pnpm audit --no-optional

When To Use

When assessing the security of essential dependencies without clutter from optional items.

Pro Tip

Be cautious: optional dependencies can still have significant vulnerabilities; ensure to validate their status regardless of exclusion from the audit.

Anatomy of Output

Understanding the result

{"advisories":[{"module":"lodash","severity":"moderate"}],"metadata":{}} Audit Result Summary

Identifies vulnerabilities only in non-optional dependencies.

"module":"lodash" Moderate Severity Vulnerability

Specifies an identified issue in a core library, excluded optional dependencies ignored.

Troubleshooting

Common pitfalls

Error: No non-optional dependencies found.

Solution: Double-check your dependency definitions in package.json.

Error: Audit process failed unexpectedly.

Solution: Run with additional logs for debugging, e.g., `pnpm audit --loglevel verbose`.

Error: Unable to reach the audit service.

Solution: Check your internet connection and try again.

Command Breakdown

What each part is doing

pnpm
Base Command
The executable that performs this operation. Here it runs Audit before the shell applies any redirect operators.
--no-optional
Command Option
Tool-specific option used by this command invocation.

Alternative Approaches

Comparable commands in other tools

Alternative package management tools for the same job.