Sonar Scanner doesn't pick up the executable from sonar.nodejs.executable

Must-share information (formatted with Markdown):

  • which versions are you using : sonarqube scanner 4.2.0
  • what are you trying to achieve : Scan UI code (node)
  • what have you tried so far to achieve this - Triggered sonar-scanner with -Dsonar.nodejs.executable=/home/ubuntu/.nvm/versions/node/v10.14.2/bin/node

We are managing node installations entirely using nvm and we DO NOT have a Globally installed node on the machine. Hence, we are adding the path to node explicitly using the below Param
Dsonar.nodejs.executable=/home/ubuntu/.nvm/versions/node/v10.14.2/bin/node

We are getting below error

 ERROR: Error during SonarQube Scanner execution
org.sonar.api.utils.command.CommandException: java.io.IOException: Cannot run program "node": error=2, No such file or directory
  at org.sonar.api.utils.command.CommandExecutor.execute(CommandExecutor.java:102)
  at io.github.sleroy.sonar.EsLintExecutorImpl.getCommandOutput(EsLintExecutorImpl.java:157)
  at io.github.sleroy.sonar.EsLintExecutorImpl.execute(EsLintExecutorImpl.java:145)
  at io.github.sleroy.sonar.EsLintSensor.execute(EsLintSensor.java:88)
  at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
  at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:57)
  at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:49)
  at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:78)
  at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:175)
  at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:143)
  at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:128)
  at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:262)
  at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:257)
  at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:247)
  at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:143)
  at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:128)
  at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
  at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
  at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:143)
  at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:128)
  at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:118)
  at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:117)
  at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:77)
  at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.base/java.lang.reflect.Method.invoke(Unknown Source)
  at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
  at com.sun.proxy.$Proxy0.execute(Unknown Source)
  at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
  at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
  at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
  at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
  at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.io.IOException: Cannot run program "node": error=2, No such file or directory
  at java.base/java.lang.ProcessBuilder.start(Unknown Source)
  at java.base/java.lang.ProcessBuilder.start(Unknown Source)
  at org.sonar.api.utils.command.CommandExecutor.execute(CommandExecutor.java:74)
  ... 34 more
Caused by: java.io.IOException: error=2, No such file or directory
  at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
  at java.base/java.lang.ProcessImpl.<init>(Unknown Source)
  at java.base/java.lang.ProcessImpl.start(Unknown Source)
  ... 37 more

Just wanted to know if we are missing some step? How do I ensure sonarqube is using the node executable which I have passed?

I observe from the error that the error is thrown from eslint plugin. I have already added path to eslint with this property
-Dsonar.eslint.eslintpath=/home/ubuntu/.nvm/versions/node/v10.14.2/bin/eslint

I assume eslint plugin is not honoring the custom node path set on sonar.nodejs.executable ??
The scanner logs show the point where eslint is executed
09:53:22.787 DEBUG: Executing EsLint with command: node /usr/bin -f json --output-file
When the sonar.nodejs.executable is explicitly set, why is sonar trying to invoke eslint via default node command?

1 Like