| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 | .TH "NPM\-AUDIT" "1" "August 2021" "" "".SH "NAME"\fBnpm-audit\fR \- Run a security audit.SS Synopsis.P.RS 2.nfnpm audit [\-\-json|\-\-parseable|\-\-audit\-level=(low|moderate|high|critical)]npm audit fix [\-\-force|\-\-package\-lock\-only|\-\-dry\-run]common options: [\-\-production] [\-\-only=(dev|prod)].fi.RE.SS Examples.PScan your project for vulnerabilities and automatically install any compatibleupdates to vulnerable dependencies:.P.RS 2.nf$ npm audit fix.fi.RE.PRun \fBaudit fix\fP without modifying \fBnode_modules\fP, but still updating thepkglock:.P.RS 2.nf$ npm audit fix \-\-package\-lock\-only.fi.RE.PSkip updating \fBdevDependencies\fP:.P.RS 2.nf$ npm audit fix \-\-only=prod.fi.RE.PHave \fBaudit fix\fP install semver\-major updates to toplevel dependencies, not justsemver\-compatible ones:.P.RS 2.nf$ npm audit fix \-\-force.fi.RE.PDo a dry run to get an idea of what \fBaudit fix\fP will do, and \fIalso\fR outputinstall information in JSON format:.P.RS 2.nf$ npm audit fix \-\-dry\-run \-\-json.fi.RE.PScan your project for vulnerabilities and just show the details, without fixinganything:.P.RS 2.nf$ npm audit.fi.RE.PGet the detailed audit report in JSON format:.P.RS 2.nf$ npm audit \-\-json.fi.RE.PGet the detailed audit report in plain text result, separated by tab characters, allowing forfuture reuse in scripting or command line post processing, like for example, selectingsome of the columns printed:.P.RS 2.nf$ npm audit \-\-parseable.fi.RE.PTo parse columns, you can use for example \fBawk\fP, and just print some of them:.P.RS 2.nf$ npm audit \-\-parseable | awk \-F $'\\t' '{print $1,$4}'.fi.RE.PFail an audit only if the results include a vulnerability with a level of moderate or higher:.P.RS 2.nf$ npm audit \-\-audit\-level=moderate.fi.RE.SS Description.PThe audit command submits a description of the dependencies configured inyour project to your default registry and asks for a report of knownvulnerabilities\. The report returned includes instructions on how to act onthis information\. The command will exit with a 0 exit code if novulnerabilities were found\..PYou can also have npm automatically fix the vulnerabilities by running \fBnpmaudit fix\fP\|\. Note that some vulnerabilities cannot be fixed automatically andwill require manual intervention or review\. Also note that since \fBnpm audit fix\fPruns a full\-fledged \fBnpm install\fP under the hood, all configs that apply to theinstaller will also apply to \fBnpm install\fP \-\- so things like \fBnpm audit fix\-\-package\-lock\-only\fP will work as expected\..PBy default, the audit command will exit with a non\-zero code if any vulnerabilityis found\. It may be useful in CI environments to include the \fB\-\-audit\-level\fP parameterto specify the minimum vulnerability level that will cause the command to fail\. Thisoption does not filter the report output, it simply changes the command's failurethreshold\..SS Content Submitted.RS 0.IP \(bu 2npm_version.IP \(bu 2node_version.IP \(bu 2platform.IP \(bu 2node_env.IP \(bu 2A scrubbed version of your package\-lock\.json or npm\-shrinkwrap\.json.RE.SS Scrubbing.PIn order to ensure that potentially sensitive information is not included inthe audit data bundle, some dependencies may have their names (and sometimesversions) replaced with opaque non\-reversible identifiers\.  It is done forthe following dependency types:.RS 0.IP \(bu 2Any module referencing a scope that is configured for a non\-defaultregistry has its name scrubbed\.  (That is, a scope you did a \fBnpm login \-\-scope=@ourscope\fP for\.).IP \(bu 2All git dependencies have their names and specifiers scrubbed\..IP \(bu 2All remote tarball dependencies have their names and specifiers scrubbed\..IP \(bu 2All local directory and tarball dependencies have their names and specifiers scrubbed\..RE.PThe non\-reversible identifiers are a sha256 of a session\-specific UUID and thevalue being replaced, ensuring a consistent value within the payload that isdifferent between runs\..SS Exit Code.PThe \fBnpm audit\fP command will exit with a 0 exit code if no vulnerabilities were found\..PIf vulnerabilities were found the exit code will depend on the \fBaudit\-level\fPconfiguration setting\..SS See Also.RS 0.IP \(bu 2npm help install.IP \(bu 2npm help package\-locks.IP \(bu 2npm help config.RE
 |