[ERROR] Error when running: 'node -v'. Is Node.js available during analysis?

Errors while running CI Bitbucket Cloud, no changes on our side.
We only have backend java code - no Node.js as usual - , the scanner command hasn’t changed for a while:

  • mvn -B sonar:sonar -Dsonar.login=$SONAR_TOKEN -P allModules -f

We get these errors:
[ERROR] /root/.sonar/js/node-runtime/node: /lib64/libm.so.6: version GLIBC_2.27' not found (required by /root/.sonar/js/node-runtime/node)*** ***[ERROR] /root/.sonar/js/node-runtime/node: /lib64/libc.so.6: version GLIBC_2.28’ not found (required by /root/.sonar/js/node-runtime/node)
[WARNING] Embedded Node.js failed to deploy. Will fallback to host Node.js.
org.sonar.plugins.javascript.nodejs.NodeCommandException: Failed to determine the version of Node.js, exit value 1. Executed: ‘/root/.sonar/js/node-runtime/node -v’
[ERROR] Error when running: ‘node -v’. Is Node.js available during analysis?
***org.sonar.plugins.javascript.nodejs.NodeCommandException: Error when running: ‘node -v’. ***
Is Node.js available during analysis?

We have never had Node.js on this java repository.
I can see some people have the same issue 13 days ago and they required a fix from SonarCloud team.

Hello Encarna,

As announced in December, the Sonar analysis now requires a Node.js runtime. This results in a hard fail, if your project has files that are analyzed by the JS/TS analyzer and no compatible Node.js runtime, is available.
To mitigate this issue, we have embedded Node.js runtimes for Linux x64, Windows x64, and MacOS ARM64, but there are some platforms that we don’t support such as Linux Alpine.

To fix your analysis, you can:

  1. install a Node.js runtime as required
  2. exclude files that are covered by the JS/TS analyzer using the following property with your analysis:
sonar.exclusions=**/*.js,**/*.jsx,**/*.cjs,**/*.mjs,**/*.vue,**/*.ts,**/*.tsx,**/*.cts,**/*.mts,**/*.html,**/*.htm,**/*.yaml

Hi Ilia ,
Thanks for the quick answer , we will try it out

Thanks & regards,
Encarna

1 Like

Hi Ilia,

The fix suggested does not work for us , since wevare triggering the sonar scanner from BitBucket pipeline ,so we need to have Bitbucket Pipe running the correct version of sonarcloud scanner. I found this in Sonar cloud documentation :
Bitbucket Pipelines
(Scanner environment & SonarCloud)

Version 2.0.0 and onward of the sonarcloud-scan Bitbucket Pipe uses the required version of Node.js. You should ensure that you specify at least version 2.0.0 of the pipe declaration in your bitbucket-pipelines.yml. For example:

  • pipe: sonarsource/sonarcloud-scan:2.0.0

I tried the above and it causes other issues because then , we bypass the sonar properties that we have in pom.xml , which we pass with command mvn -B sonar:sonar -Dsonar…
If we adopt - pipe: sonarsource/sonarcloud-scan:2.0.0, can we pass the sonar properties using a property file such as .sonarcloud.properties? Is this the file name that we need to use ?

Thanks & regards

Hi Encarna,

If you simply try to update your scanner version (1) as you did, what do you get?

- pipe: sonarsource/sonarcloud-scan:2.0.0

If this leads to an OOM issue, could you try to add this option to raise the amount of RAM available for the Node.js process in the analyzer (2), as it was proposed in this thread:

- pipe: sonarsource/sonarcloud-scan:2.0.0
  variables:
    EXTRA_ARGS: '-Dsonar.javascript.node.maxspace=4096'

If the issue persists, could you join your log files here?

I tried the above and it causes other issues because then , we bypass the sonar properties that we have in pom.xml , which we pass with command mvn -B sonar:sonar -Dsonar…

You mean that trying (1) led to some issues with your Maven scan job?

If we adopt - pipe: sonarsource/sonarcloud-scan:2.0.0, can we pass the sonar properties using a property file such as .sonarcloud.properties? Is this the file name that we need to use ?

You can pass them in EXTRA_ARGS as shown in (2). Would that fit?

Hi Ilia ,
These works and the SonarCloud is successful (together with the sonar-project.properties )

  • pipe: sonarsource/sonarcloud-scan:2.0.0
    variables:
    EXTRA_ARGS: ‘-Dsonar.javascript.node.maxspace=4096’
But we have some concern because in other part of the documentation says that we should no use pipe commands with maven projects - even though it runs fine for our maven projects -

![image|690x336](upload://mTnQGVX13u1Ob9Tu4qzBfs5HEI2.png)

Sorry , the screen shot didn’t load

Could you check that your maven project properties are not ignored?

They are ignored as mvn -B verify sonar:sonar … is not run , but it is ok if they are provided in sonar-project.properties. Properties are read from property file when the sonar step is run