1<!DOCTYPE html><html><head> 2<meta charset="utf-8"> 3<title>npm-sbom</title> 4<style> 5body { 6 background-color: #ffffff; 7 color: #24292e; 8 9 margin: 0; 10 11 line-height: 1.5; 12 13 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; 14} 15#rainbar { 16 height: 10px; 17 background-image: linear-gradient(139deg, #fb8817, #ff4b01, #c12127, #e02aff); 18} 19 20a { 21 text-decoration: none; 22 color: #0366d6; 23} 24a:hover { 25 text-decoration: underline; 26} 27 28pre { 29 margin: 1em 0px; 30 padding: 1em; 31 border: solid 1px #e1e4e8; 32 border-radius: 6px; 33 34 display: block; 35 overflow: auto; 36 37 white-space: pre; 38 39 background-color: #f6f8fa; 40 color: #393a34; 41} 42code { 43 font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; 44 font-size: 85%; 45 padding: 0.2em 0.4em; 46 background-color: #f6f8fa; 47 color: #393a34; 48} 49pre > code { 50 padding: 0; 51 background-color: inherit; 52 color: inherit; 53} 54h1, h2, h3 { 55 font-weight: 600; 56} 57 58#logobar { 59 background-color: #333333; 60 margin: 0 auto; 61 padding: 1em 4em; 62} 63#logobar .logo { 64 float: left; 65} 66#logobar .title { 67 font-weight: 600; 68 color: #dddddd; 69 float: left; 70 margin: 5px 0 0 1em; 71} 72#logobar:after { 73 content: ""; 74 display: block; 75 clear: both; 76} 77 78#content { 79 margin: 0 auto; 80 padding: 0 4em; 81} 82 83#table_of_contents > h2 { 84 font-size: 1.17em; 85} 86#table_of_contents ul:first-child { 87 border: solid 1px #e1e4e8; 88 border-radius: 6px; 89 padding: 1em; 90 background-color: #f6f8fa; 91 color: #393a34; 92} 93#table_of_contents ul { 94 list-style-type: none; 95 padding-left: 1.5em; 96} 97#table_of_contents li { 98 font-size: 0.9em; 99} 100#table_of_contents li a { 101 color: #000000; 102} 103 104header.title { 105 border-bottom: solid 1px #e1e4e8; 106} 107header.title > h1 { 108 margin-bottom: 0.25em; 109} 110header.title > .description { 111 display: block; 112 margin-bottom: 0.5em; 113 line-height: 1; 114} 115 116footer#edit { 117 border-top: solid 1px #e1e4e8; 118 margin: 3em 0 4em 0; 119 padding-top: 2em; 120} 121</style> 122</head> 123<body> 124<div id="banner"> 125<div id="rainbar"></div> 126<div id="logobar"> 127<svg class="logo" role="img" height="32" width="32" viewBox="0 0 700 700"> 128<polygon fill="#cb0000" points="0,700 700,700 700,0 0,0"></polygon> 129<polygon fill="#ffffff" points="150,550 350,550 350,250 450,250 450,550 550,550 550,150 150,150"></polygon> 130</svg> 131<div class="title"> 132npm command-line interface 133</div> 134</div> 135</div> 136 137<section id="content"> 138<header class="title"> 139<h1 id="npm-sbom">npm-sbom</h1> 140<span class="description">Generate a Software Bill of Materials (SBOM)</span> 141</header> 142 143<section id="table_of_contents"> 144<h2 id="table-of-contents">Table of contents</h2> 145<div id="_table_of_contents"><ul><li><a href="#see-also">See Also</a></li></ul></div> 146</section> 147 148<div id="_content"><h3 id="synopsis">Synopsis</h3> 149<pre><code class="language-bash">npm sbom 150</code></pre> 151<h3 id="description">Description</h3> 152<p>The <code>npm sbom</code> command generates a Software Bill of Materials (SBOM) listing the 153dependencies for the current project. SBOMs can be generated in either 154<a href="https://spdx.dev/">SPDX</a> or <a href="https://cyclonedx.org/">CycloneDX</a> format.</p> 155<h3 id="example-cyclonedx-sbom">Example CycloneDX SBOM</h3> 156<pre><code class="language-json">{ 157 "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json", 158 "bomFormat": "CycloneDX", 159 "specVersion": "1.5", 160 "serialNumber": "urn:uuid:09f55116-97e1-49cf-b3b8-44d0207e7730", 161 "version": 1, 162 "metadata": { 163 "timestamp": "2023-09-01T00:00:00.001Z", 164 "lifecycles": [ 165 { 166 "phase": "build" 167 } 168 ], 169 "tools": [ 170 { 171 "vendor": "npm", 172 "name": "cli", 173 "version": "10.1.0" 174 } 175 ], 176 "component": { 177 "bom-ref": "simple@1.0.0", 178 "type": "library", 179 "name": "simple", 180 "version": "1.0.0", 181 "scope": "required", 182 "author": "John Doe", 183 "description": "simple react app", 184 "purl": "pkg:npm/simple@1.0.0", 185 "properties": [ 186 { 187 "name": "cdx:npm:package:path", 188 "value": "" 189 } 190 ], 191 "externalReferences": [], 192 "licenses": [ 193 { 194 "license": { 195 "id": "MIT" 196 } 197 } 198 ] 199 } 200 }, 201 "components": [ 202 { 203 "bom-ref": "lodash@4.17.21", 204 "type": "library", 205 "name": "lodash", 206 "version": "4.17.21", 207 "scope": "required", 208 "author": "John-David Dalton", 209 "description": "Lodash modular utilities.", 210 "purl": "pkg:npm/lodash@4.17.21", 211 "properties": [ 212 { 213 "name": "cdx:npm:package:path", 214 "value": "node_modules/lodash" 215 } 216 ], 217 "externalReferences": [ 218 { 219 "type": "distribution", 220 "url": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz" 221 }, 222 { 223 "type": "vcs", 224 "url": "git+https://github.com/lodash/lodash.git" 225 }, 226 { 227 "type": "website", 228 "url": "https://lodash.com/" 229 }, 230 { 231 "type": "issue-tracker", 232 "url": "https://github.com/lodash/lodash/issues" 233 } 234 ], 235 "hashes": [ 236 { 237 "alg": "SHA-512", 238 "content": "bf690311ee7b95e713ba568322e3533f2dd1cb880b189e99d4edef13592b81764daec43e2c54c61d5c558dc5cfb35ecb85b65519e74026ff17675b6f8f916f4a" 239 } 240 ], 241 "licenses": [ 242 { 243 "license": { 244 "id": "MIT" 245 } 246 } 247 ] 248 } 249 ], 250 "dependencies": [ 251 { 252 "ref": "simple@1.0.0", 253 "dependsOn": [ 254 "lodash@4.17.21" 255 ] 256 }, 257 { 258 "ref": "lodash@4.17.21", 259 "dependsOn": [] 260 } 261 ] 262} 263</code></pre> 264<h3 id="example-spdx-sbom">Example SPDX SBOM</h3> 265<pre><code class="language-json">{ 266 "spdxVersion": "SPDX-2.3", 267 "dataLicense": "CC0-1.0", 268 "SPDXID": "SPDXRef-DOCUMENT", 269 "name": "simple@1.0.0", 270 "documentNamespace": "http://spdx.org/spdxdocs/simple-1.0.0-bf81090e-8bbc-459d-bec9-abeb794e096a", 271 "creationInfo": { 272 "created": "2023-09-01T00:00:00.001Z", 273 "creators": [ 274 "Tool: npm/cli-10.1.0" 275 ] 276 }, 277 "documentDescribes": [ 278 "SPDXRef-Package-simple-1.0.0" 279 ], 280 "packages": [ 281 { 282 "name": "simple", 283 "SPDXID": "SPDXRef-Package-simple-1.0.0", 284 "versionInfo": "1.0.0", 285 "packageFileName": "", 286 "description": "simple react app", 287 "primaryPackagePurpose": "LIBRARY", 288 "downloadLocation": "NOASSERTION", 289 "filesAnalyzed": false, 290 "homepage": "NOASSERTION", 291 "licenseDeclared": "MIT", 292 "externalRefs": [ 293 { 294 "referenceCategory": "PACKAGE-MANAGER", 295 "referenceType": "purl", 296 "referenceLocator": "pkg:npm/simple@1.0.0" 297 } 298 ] 299 }, 300 { 301 "name": "lodash", 302 "SPDXID": "SPDXRef-Package-lodash-4.17.21", 303 "versionInfo": "4.17.21", 304 "packageFileName": "node_modules/lodash", 305 "description": "Lodash modular utilities.", 306 "downloadLocation": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", 307 "filesAnalyzed": false, 308 "homepage": "https://lodash.com/", 309 "licenseDeclared": "MIT", 310 "externalRefs": [ 311 { 312 "referenceCategory": "PACKAGE-MANAGER", 313 "referenceType": "purl", 314 "referenceLocator": "pkg:npm/lodash@4.17.21" 315 } 316 ], 317 "checksums": [ 318 { 319 "algorithm": "SHA512", 320 "checksumValue": "bf690311ee7b95e713ba568322e3533f2dd1cb880b189e99d4edef13592b81764daec43e2c54c61d5c558dc5cfb35ecb85b65519e74026ff17675b6f8f916f4a" 321 } 322 ] 323 } 324 ], 325 "relationships": [ 326 { 327 "spdxElementId": "SPDXRef-DOCUMENT", 328 "relatedSpdxElement": "SPDXRef-Package-simple-1.0.0", 329 "relationshipType": "DESCRIBES" 330 }, 331 { 332 "spdxElementId": "SPDXRef-Package-simple-1.0.0", 333 "relatedSpdxElement": "SPDXRef-Package-lodash-4.17.21", 334 "relationshipType": "DEPENDS_ON" 335 } 336 ] 337} 338</code></pre> 339<h3 id="package-lock-only-mode">Package lock only mode</h3> 340<p>If package-lock-only is enabled, only the information in the package 341lock (or shrinkwrap) is loaded. This means that information from the 342package.json files of your dependencies will not be included in the 343result set (e.g. description, homepage, engines).</p> 344<h3 id="configuration">Configuration</h3> 345<h4 id="omit"><code>omit</code></h4> 346<ul> 347<li>Default: 'dev' if the <code>NODE_ENV</code> environment variable is set to 348'production', otherwise empty.</li> 349<li>Type: "dev", "optional", or "peer" (can be set multiple times)</li> 350</ul> 351<p>Dependency types to omit from the installation tree on disk.</p> 352<p>Note that these dependencies <em>are</em> still resolved and added to the 353<code>package-lock.json</code> or <code>npm-shrinkwrap.json</code> file. They are just not 354physically installed on disk.</p> 355<p>If a package type appears in both the <code>--include</code> and <code>--omit</code> lists, then 356it will be included.</p> 357<p>If the resulting omit list includes <code>'dev'</code>, then the <code>NODE_ENV</code> environment 358variable will be set to <code>'production'</code> for all lifecycle scripts.</p> 359<h4 id="package-lock-only"><code>package-lock-only</code></h4> 360<ul> 361<li>Default: false</li> 362<li>Type: Boolean</li> 363</ul> 364<p>If set to true, the current operation will only use the <code>package-lock.json</code>, 365ignoring <code>node_modules</code>.</p> 366<p>For <code>update</code> this means only the <code>package-lock.json</code> will be updated, 367instead of checking <code>node_modules</code> and downloading dependencies.</p> 368<p>For <code>list</code> this means the output will be based on the tree described by the 369<code>package-lock.json</code>, rather than the contents of <code>node_modules</code>.</p> 370<h4 id="sbom-format"><code>sbom-format</code></h4> 371<ul> 372<li>Default: null</li> 373<li>Type: "cyclonedx" or "spdx"</li> 374</ul> 375<p>SBOM format to use when generating SBOMs.</p> 376<h4 id="sbom-type"><code>sbom-type</code></h4> 377<ul> 378<li>Default: "library"</li> 379<li>Type: "library", "application", or "framework"</li> 380</ul> 381<p>The type of package described by the generated SBOM. For SPDX, this is the 382value for the <code>primaryPackagePurpose</code> field. For CycloneDX, this is the 383value for the <code>type</code> field.</p> 384<h4 id="workspace"><code>workspace</code></h4> 385<ul> 386<li>Default:</li> 387<li>Type: String (can be set multiple times)</li> 388</ul> 389<p>Enable running a command in the context of the configured workspaces of the 390current project while filtering by running only the workspaces defined by 391this configuration option.</p> 392<p>Valid values for the <code>workspace</code> config are either:</p> 393<ul> 394<li>Workspace names</li> 395<li>Path to a workspace directory</li> 396<li>Path to a parent workspace directory (will result in selecting all 397workspaces within that folder)</li> 398</ul> 399<p>When set for the <code>npm init</code> command, this may be set to the folder of a 400workspace which does not yet exist, to create the folder and set it up as a 401brand new workspace within the project.</p> 402<p>This value is not exported to the environment for child processes.</p> 403<h4 id="workspaces"><code>workspaces</code></h4> 404<ul> 405<li>Default: null</li> 406<li>Type: null or Boolean</li> 407</ul> 408<p>Set to true to run the command in the context of <strong>all</strong> configured 409workspaces.</p> 410<p>Explicitly setting this to false will cause commands like <code>install</code> to 411ignore workspaces altogether. When not set explicitly:</p> 412<ul> 413<li>Commands that operate on the <code>node_modules</code> tree (install, update, etc.) 414will link workspaces into the <code>node_modules</code> folder. - Commands that do 415other things (test, exec, publish, etc.) will operate on the root project, 416<em>unless</em> one or more workspaces are specified in the <code>workspace</code> config.</li> 417</ul> 418<p>This value is not exported to the environment for child processes.</p> 419<h2 id="see-also">See Also</h2> 420<ul> 421<li><a href="../using-npm/package-spec.html">package spec</a></li> 422<li><a href="../using-npm/dependency-selectors.html">dependency selectors</a></li> 423<li><a href="../configuring-npm/package-json.html">package.json</a></li> 424<li><a href="../using-npm/workspaces.html">workspaces</a></li> 425</ul></div> 426 427<footer id="edit"> 428<a href="https://github.com/npm/cli/edit/latest/docs/content/commands/npm-sbom.md"> 429<svg role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentcolor" style="vertical-align: text-bottom; margin-right: 0.3em;"> 430<path fill-rule="evenodd" d="M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 000-.354l-1.086-1.086zM11.189 6.25L9.75 4.81l-6.286 6.287a.25.25 0 00-.064.108l-.558 1.953 1.953-.558a.249.249 0 00.108-.064l6.286-6.286z"></path> 431</svg> 432Edit this page on GitHub 433</a> 434</footer> 435</section> 436 437 438 439</body></html>