The `sonar-scanner` npm package serves as a convenient Node.js wrapper for the official, Java-based SonarQube Scanner command-line interface. It simplifies the integration of SonarQube code analysis into Node.js projects by providing an `npm install` and `npm run` entry point, eliminating the need for manual downloads and path configurations of the SonarQube Scanner CLI. The current stable version, 3.1.0, was last published in February 2021. While the wrapper itself has seen limited recent development, its primary function is to proxy commands to the underlying SonarQube Scanner, which continues to evolve independently. Its key differentiator is providing a straightforward Node.js ecosystem entry for SonarQube analysis, primarily aimed at CI/CD pipelines within JavaScript/TypeScript projects.
npm install sonar-scannerVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to integrate `sonar-scanner` into a Node.js project's `package.json` scripts for SonarQube analysis, configuring basic project properties and token authentication.
Ensure Java (JRE/JDK 11 or higher, depending on SonarQube server version) is installed and accessible in your system's PATH.
Always invoke `sonar-scanner` via `npm scripts` or directly from `node_modules/.bin/sonar-scanner` as a command-line tool.
Review the official SonarQube documentation for the latest scanner capabilities and consider if a newer wrapper or direct use of the official scanner is necessary for advanced features or compatibility with very new SonarQube server versions.
Provide all mandatory SonarQube properties either inline in your `npm script` (e.g., `-Dsonar.projectKey=my-key`) or in a `sonar-project.properties` file.
Install a supported Java version (e.g., OpenJDK 11 or newer) and ensure `JAVA_HOME` is set to its installation directory, and the `bin` directory is in your system's PATH.
Add `-Dsonar.projectKey=<your-project-key>` to your `sonar-scanner` command in `package.json` or define it in your `sonar-project.properties` file.
Ensure the `SONAR_TOKEN` environment variable is correctly set with a valid token, or pass it via `-Dsonar.token=your_token` in the command. Verify the token's permissions on the SonarQube server.
No dependency data recorded yet.