NodeJs setting version using the SonarQube NPM module

Hello. I am not a Node developer. But I have to perform the scans for SonarQube. I am using the NPM module sonarqube-scanner which is working perfectly. I tried using the commandline option -Dsonar.projectVersion=1.1 with “npm run sonar -D” to pass in the version number. But it’s doesn’t work. What am I doing wrong? Please help.

Hi @SonarFrog ,

You cannot pass Java system properties (i.e. the Sonar scanner analysis parameters) through npm run sonar. You need to place your analysis parameters like sonar.projectversion inside a file that passes those values to the sonarqube-scanner. See the readme for the sonar-scanner-npm module: GitHub - bellingard/sonar-scanner-npm: SonarQube Scanner for the JavaScript world

Another way is to skip the usage of the NPM module and just use the sonar-scanner CLI directly, which then allows you to pass the analysis parameters at the command line. See here for more: