SonarQube Scanner for the JavaScript world
Branch: master
Clone or download
bellingard Merge pull request #65 from henryju/patch-1
Update Scanner CLI to
Latest commit 735cf8b Feb 19, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist Update Scanner CLI to Feb 18, 2019
specs #64 Do not provide default setting values when not supplied Feb 12, 2019
.eslintignore Add eslint config files Oct 13, 2017
.gitignore Merge branch 'master' into Sep 17, 2017 Activate the automatic analysis of the repo on SC Dec 19, 2018
.travis.yml add execution report Sep 15, 2017
LICENSE Update LICENSE file Oct 16, 2016 #59 Document issue with Alpine-based Docker images Feb 14, 2019
gulpfile.js Update project title Nov 8, 2018
package.json Preapre next development cycle Feb 19, 2019

NPM module to run SonarQube/SonarCloud analyses

sonarqube-scanner makes it very easy to trigger SonarQube / SonarCloud analyses on a JavaScript code base, without needing to install any specific tool or (Java) runtime.

This module is analyzed on SonarCloud using itself:

Build status Quality Gate Coverage Maintainability Reliability Security Releases


This package is available on npm as: sonarqube-scanner

To add code analysis to your build files, simply add the package to your project dev dependencies:

npm install -D sonarqube-scanner

To install the scanner globally and be able to run analyses on the command line:

npm install -g sonarqube-scanner

Usage: add code analysis to your build files

Prerequisite: you've installed the package as a dev dependency.

The following example shows how to run an analysis on a JavaScript project using Gulp, and pushing the results to SonarCloud, the online code-analysis service based on SonarQube:

var gulp = require('gulp');
var sonarqubeScanner = require('sonarqube-scanner');

gulp.task('default', function(callback) {
    serverUrl : "",
    token : "019d1e2e04eefdcd0caee1468f39a45e69d33d3f",
    options : {
      "sonar.organization": "my-org"
  }, callback);

Syntax: sonarqube-scanner ( parameters, [callback] )


  • parameters Map
    • serverUrl String (optional) The URL of the SonarQube server. Defaults to http://localhost:9000
    • token String (optional) The token used to connect to the SonarQube server. Empty by default.
    • options Map (optional) Used to pass extra parameters for the SonarQube analysis. See the official documentation for more details.
  • callback Function (optional) Callback (the execution of the analysis is asynchronous).

Usage: run analyses on the command line

Prerequisite: you've installed the package globally.

If you want to run an analysis without having to configure anything in the first place, simply run the sonar-scanner command. The following example assumes that you have installed SonarQube locally:

cd my-project

Specifying properties/settings

  • If there's a package.json file in the folder, it will be read to feed the analysis with basic information (like project name or version)
  • If there's a file in the folder, it will behave like the original SonarQube Scanner
  • Additional analysis parameters can be passed on the command line using the standard syntax
    • Example:

      sonar-scanner -Dsonar.login=019d1e2e04e


I constantly get "Impossible to download and extract binary [...] In such situation, the best solution is to install the standard SonarQube Scanner", what can I do?

You can install manually the standard SonarQube Scanner, which requires to have a Java Runtime Environment available too (Java 8+). Once this is done, you can replace the 2nd line of the example by:

var sonarqubeScanner = require('sonarqube-scanner').customScanner;

In my Docker container, the scanner fails with ".../jre/bin/java: not found", how do I solve this?

You are probably relying on Alpine for your Docker image, and Alpine does not include glibc by default. It needs to be installed manually.

Thanks to Philipp Eschenbach for troubleshooting this on issue #59.

Download From Mirrors

By default, SonarQube scanner binaries are downloaded from To use a custom mirror, set $SONAR_SCANNER_MIRROR.




sonarqube-scanner is licensed under the LGPL v3 License.