> For the complete documentation index, see [llms.txt](https://docs.sealights.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/legacy-commands-deprecated/backend-server-application/scanning-a-build.md).

# Scanning a Build

## Scanning a build <a href="#scanning-a-build" id="scanning-a-build"></a>

Scanning a build in Node.js is done using the Node.js Build scanner with the build flag.

{% code overflow="wrap" %}

```sh
npx slnodejs scan --tokenFile ./sltoken.txt --buildSessionIdFile buildSessionId --scanDir "." --scmType git --es6Modules
```

{% endcode %}

{% hint style="warning" %}
For React applications, you should add the flag: `--babylonPlugin jsx`. To scan both `.ts` and `.tsx` files, you should add the flag: `--babylonPlugins typescript,jsx`
{% endhint %}

{% hint style="info" %}

* In order to ignore specific files or folders during the Scan operation, please refer to [Ignoring Files or Folders](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/legacy-commands-deprecated/ignoring-files-or-folders.md)
* For "`JavaScript heap out of memory`" errors while running scan, see: [NodeJS - JavaScript heap out of memory](/knowledgebase/setup-and-configuration/troubleshooting-faq/node-javascript/nodejs-javascript-heap-out-of-memory.md)
* See [Command Reference](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/go-agent/go-agent-v1/command-reference.md#scanning-a-build) for full parameter details
  {% endhint %}

## Scanning a ts-node build <a href="#scanning-a-ts-node-build" id="scanning-a-ts-node-build"></a>

Scanning a build in Node.js is done using the Node.js Build scanner with the scan command flag and requires:

* explicit type of files (`.ts` and/or `.tsx`) in a dedicated environment variable `SL_fileExtensions`
* scan the application files with the `--scanDir` parameter pointing to the source files directory (`.ts`)

{% tabs %}
{% tab title="Unix" %}
{% code overflow="wrap" %}

```sh
export SL_fileExtensions=".ts,.tsx"

npx slnodejs scan --tokenFile /path/to/sltoken.txt --buildSessionIdFile buildSessionId --scanDir "./src" --scmType git 
```

{% endcode %}
{% endtab %}

{% tab title="Windows" %}
{% code overflow="wrap" %}

```powershell
export SL_fileExtensions=".ts,.tsx"

call npx slnodejs scan --tokenFile \path\to\sltoken.txt --buildSessionIdFile buildSessionId --scanDir ".\src" --scmType git 
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Scanning multi modules <a href="#scanning-multi-modules" id="scanning-multi-modules"></a>

If you want to report separate parts of the application as separate modules, you can do so by scanning each part with the `--uniqueModuleId` option.

When you finish reporting all the modules, you need to send the event with the `buildend` command and either the `--ok` or `--failed` depending on the result of your build process.

{% hint style="warning" %}
It is important to always use the exact **same module names each time** you report a new build.
{% endhint %}

{% code overflow="wrap" lineNumbers="true" fullWidth="false" %}

```sh
npx slnodejs scan --tokenFile ./path/to/sltoken.txt --buildSessionIdFile buildSessionId --scanDir "." --scmType git --es6Modules --uniqueModuleId module-name-one 
npx slnodejs scan --tokenFile ./path/to/sltoken.txt --buildSessionIdFile buildSessionId --scanDir "." --scmType git --es6Modules --uniqueModuleId module-name-two

npx slnodejs buildend --tokenFile ./path/to/sltoken.txt --buildSessionIdFile buildSessionId --ok
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/legacy-commands-deprecated/backend-server-application/scanning-a-build.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
