How to send GitLab variable to sonarqube-scanner.js for JavaScript

I can scan my React code now (from GitLab to SonarQube), the problem is I need to put some data in sonarqube-scanner.js like the following. Is it possible to use GitLab environemnt (or system environment variable) in sonarqube-scanner.js ?

serverUrl : ‘’,
token : “019d1e2e04eefdcd0caee1468f39a45e69d33d3f”,
options: {
‘sonar.projectName’: ‘My App’,
‘sonar.projectDescription’: ‘Description for “My App” project…’,
‘sonar.sources’: ‘dist’,
‘sonar.tests’: ‘specs’

Hey there.

The sonarqube-scanner NPM package isn’t actually maintained by SonarSource. If you have questions about it you should reach out to the maintainer.

With that said, I have to wonder what the benefits are of using this over a more traditional method of analyzing with Gitlab CI/CD where you simply can inject the variables into your gitlab-ci.yml file.

Thanks for your suggestion, I just migrate to your solution, it’s better.
And I have another dotNet program, I use “dotnet SonarScanner.MSBuild.dll” to scan code, should I change to this solution too?