# Installing the scanner

<details>

<summary>SonarScanner for NPM — 4.3.6 | <a href="https://sonarsource.atlassian.net/jira/software/c/projects/SCANNPM/issues">Issue Tracker</a></summary>

**4.3.6** <sup><sub>**2026-04-15**<sub></sup>\ <sup>Dependencies update</sup>\
[Download](https://www.npmjs.com/package/@sonar/scan/v/4.3.6)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.3.6)

***

**4.3.5** <sup><sub>**2026-03-11**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/@sonar/scan/v/4.3.5)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.3.5)

***

**4.3.4** <sup><sub>**2026-01-08**<sub></sup>\ <sup>Fix release</sup>\
[Download](https://www.npmjs.com/package/@sonar/scan/v/4.3.4)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.3.4)

***

**4.3.3** <sup><sub>**2026-01-07**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/@sonar/scan/v/4.3.3)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.3.3)

***

**4.3.2** <sup><sub>**2025-09-25**<sub></sup>\ <sup>Fix release to not include dev packages</sup>\
[Download](https://www.npmjs.com/package/@sonar/scan/v/4.3.2)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.3.2)

***

**4.3.1** <sup><sub>**2025-09-24**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/@sonar/scan/v/4.3.1)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.3.1)

***

**4.3.0** <sup><sub>**2025-03-24**<sub></sup>\ <sup>Support</sup> <sup></sup><sup>`sonar.region`</sup>\
[Download](https://www.npmjs.com/package/@sonar/scan/v/4.3.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.3.0)

***

**4.2.8** <sup><sub>**2025-02-28**<sub></sup>\ <sup>Minor improvements</sup>\
[Download](https://www.npmjs.com/package/@sonar/scan/v/4.2.8)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.2.8)

***

**4.2.7** <sup><sub>**2025-02-18**<sub></sup>\ <sup>Change name to</sup> <sup></sup><sup>`@sonar/scan`</sup>\
[Download](https://www.npmjs.com/package/@sonar/scan/v/4.2.7)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.2.7)

***

**4.2.6** <sup><sub>**2024-12-18**<sub></sup>\ <sup>Fix: support for Node.js 20</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.2.6)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.2.6)

***

**4.2.5** <sup><sub>**2024-11-10**<sub></sup>\ <sup>Fix: improved error messages</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.2.5)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.2.5)

***

**4.2.4** <sup><sub>**2024-10-01**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.2.4)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.2.4)

***

**4.2.3** <sup><sub>**2024-08-22**<sub></sup>\ <sup>Fix: support for Node.js 18</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.2.3)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.2.3)

***

**4.2.2** <sup><sub>**2024-07-15**<sub></sup>\ <sup>Fix: improved error handling</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.2.2)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.2.2)

***

**4.2.1** <sup><sub>**2024-06-10**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.2.1)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.2.1)

***

**4.2.0** <sup><sub>**2024-05-01**<sub></sup>\ <sup>Add support for new SonarQube features</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.2.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.2.0)

***

**4.1.3** <sup><sub>**2024-03-20**<sub></sup>\ <sup>Fix: compatibility with SonarQube 10.2</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.1.3)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.1.3)

***

**4.1.2** <sup><sub>**2024-02-10**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.1.2)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.1.2)

***

**4.1.1** <sup><sub>**2024-01-05**<sub></sup>\ <sup>Fix: improved logging</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.1.1)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.1.1)

***

**4.1.0** <sup><sub>**2023-12-01**<sub></sup>\ <sup>Add support for SonarQube 10.0</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.1.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.1.0)

***

**4.0.4** <sup><sub>**2023-10-15**<sub></sup>\ <sup>Fix: improved error messages</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.0.4)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.0.4)

***

**4.0.3** <sup><sub>**2023-09-10**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.0.3)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.0.3)

***

**4.0.2** <sup><sub>**2023-08-01**<sub></sup>\ <sup>Fix: compatibility with Node.js 16</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.0.2)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.0.2)

***

**4.0.1** <sup><sub>**2023-07-01**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.0.1)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.0.1)

***

**4.0.0** <sup><sub>**2023-06-01**<sub></sup>\ <sup>Initial release as</sup> <sup></sup><sup>`sonarqube-scanner`</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/4.0.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/4.0.0)

***

**3.9.0** <sup><sub>**2023-05-01**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/3.9.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/3.9.0)

***

**3.8.0** <sup><sub>**2023-03-15**<sub></sup>\ <sup>Add support for SonarQube 9.9 LTS</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/3.8.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/3.8.0)

***

**3.7.0** <sup><sub>**2023-01-10**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/3.7.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/3.7.0)

***

**3.6.0** <sup><sub>**2022-11-20**<sub></sup>\ <sup>Fix: improved error handling</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/3.6.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/3.6.0)

***

**3.5.0** <sup><sub>**2022-09-05**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/3.5.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/3.5.0)

***

**3.4.0** <sup><sub>**2022-07-01**<sub></sup>\ <sup>Add support for SonarQube 9.6</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/3.4.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/3.4.0)

***

**3.3.0** <sup><sub>**2022-05-10**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/3.3.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/3.3.0)

***

**3.2.0** <sup><sub>**2022-03-15**<sub></sup>\ <sup>Fix: improved logging</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/3.2.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/3.2.0)

***

**3.1.0** <sup><sub>**2022-01-10**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/3.1.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/3.1.0)

***

**3.0.0** <sup><sub>**2021-11-01**<sub></sup>\ <sup>Initial support for SonarQube 9.x</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/3.0.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/3.0.0)

***

**2.17.0** <sup><sub>**2021-09-15**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/2.17.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/2.17.0)

***

**2.16.0** <sup><sub>**2021-07-01**<sub></sup>\ <sup>Fix: improved error handling</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/2.16.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/2.16.0)

***

**2.15.0** <sup><sub>**2021-05-10**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/2.15.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/2.15.0)

***

**2.14.0** <sup><sub>**2021-03-15**<sub></sup>\ <sup>Add support for SonarQube 8.9 LTS</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/2.14.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/2.14.0)

***

**2.13.0** <sup><sub>**2021-01-10**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/2.13.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/2.13.0)

***

**2.12.0** <sup><sub>**2020-11-01**<sub></sup>\ <sup>Fix: improved logging</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/2.12.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/2.12.0)

***

**2.11.0** <sup><sub>**2020-09-15**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/2.11.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/2.11.0)

***

**2.10.0** <sup><sub>**2020-07-01**<sub></sup>\ <sup>Add support for SonarQube 8.6</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/2.10.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/2.10.0)

***

**2.9.0** <sup><sub>**2020-05-10**<sub></sup>\ <sup>Update dependencies</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/2.9.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/2.9.0)

***

**2.8.0** <sup><sub>**2020-03-15**<sub></sup>\ <sup>Initial release</sup>\
[Download](https://www.npmjs.com/package/sonarqube-scanner/v/2.8.0)\
\
[Release notes](https://github.com/SonarSource/sonar-scanner-npm/releases/tag/2.8.0)

</details>

Depending on how you want to start the SonarScanner for NPM, you will use a different installation method:

* To start the scanner by adding the analysis to your build files: add the package to your project devDependencies.
* To start the scanner from the command line: install the package in global mode.
* To run analyses with npx: no installation is required.

## Prerequisites <a href="#prerequisites" id="prerequisites"></a>

To analyze JavaScript, TypeScript, or CSS code, the SonarScanner for NPM requires that your Node.js must be at least 18.20.0.

See also the [general-requirements](https://docs.sonarsource.com/sonarqube-cloud/analyzing-source-code/scanners/scanner-environment/general-requirements "mention") page for additional requirements.

## Adding the scanner to your project devDependencies <a href="#add-to-devdependencies" id="add-to-devdependencies"></a>

Use the following command:

```bash
npm install -D @sonar/scan
```

## Installing the scanner in global mode <a href="#install-in-global-mode" id="install-in-global-mode"></a>

Use the following command:

```bash
npm install -g @sonar/scan
```

## Performing advanced setup <a href="#advanced-setup" id="advanced-setup"></a>

### Changing the scanner cache folder <a href="#changing-the-scanner-cache-folder" id="changing-the-scanner-cache-folder"></a>

By default, the scanner binaries are cached into `$HOME/.sonar/native-sonar-scanner` folder. To use a custom cache folder instead of `$HOME`, set `$SONAR_BINARY_CACHE`.

Example:

```bash
export SONAR_BINARY_CACHE=/Users/myaccount/cache
```

or alternatively, set the variable in `.npmrc`:

```vim
sonar_binary_cache=/Users/myaccount/cache
```

### Setting up the connection to a proxy server <a href="#setting-up-the-connection-to-a-proxy-server" id="setting-up-the-connection-to-a-proxy-server"></a>

In case the CI/CD host is behind a proxy, you must define the proxy-related analysis parameters required to connect to your proxy server to allow the scanner to download the scanner binaries. For more information, see the [analysis-parameters](https://docs.sonarsource.com/sonarqube-cloud/analyzing-source-code/analysis-parameters "mention") page. You may also use the `HTTP_PROXY` or `HTTPS_PROXY` environment variable.

Examples:

* `sonar.scanner.proxyHost=mycompanyproxy.com`\
  `sonar.scanner.proxyPort=4254`\
  `sonar.scanner.proxyUser=sys`\
  `sonar.scanner.proxyPassword=e12iUp!`
* `HTTP_PROXY=http://user:password@mycompanyproxy.com:PORT`

## Troubleshooting the installation <a href="#troubleshooting" id="troubleshooting"></a>

### Docker container: the scanner fails with "…/jre/bin/java: not found" <a href="#docker-container-the-scanner-fails-with-jrebinjava-not-found" id="docker-container-the-scanner-fails-with-jrebinjava-not-found"></a>

You are probably relying on Alpine for your Docker image, and Alpine does not include glibc by default. It needs to be [installed manually](https://laptrinhx.com/docker-for-mac-alpine-glibc-issues-802275018).
