Receiving the below error when scanning react ts project using sconarcloud version 1.46 in Azure DevOps pipeline.:
ERROR: Unsupported Node.JS version detected 18.12.1. Please upgrade to the latest Node.JS LTS version.
Receiving the below error when scanning react ts project using sconarcloud version 1.46 in Azure DevOps pipeline.:
ERROR: Unsupported Node.JS version detected 18.12.1. Please upgrade to the latest Node.JS LTS version.
More details: My project is using node 18.20. (React)
Logs:
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.scanner.bootstrap.ScannerContainer.doAfterStart(ScannerContainer.java:399)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:131)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:60)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:54)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at jdk.proxy1/jdk.proxy1.$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:126)
at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
at org.sonarsource.scanner.cli.Main.main(Main.java:62)
ERROR: Unsupported Node.JS version detected 18.12.1. Please upgrade to the latest Node.JS LTS version.
Tried in different azure devops pipeline agent like windows and macos, and the result is same.
Hey there.
Are these microsoft-hosted agents or self-hosted agents?
Hi, These are for Microsoft-hosted agents.
Thanks. That’s super strange then
Can you share your full Azure Pipelines YML file?
Please find the pipeline yaml file:
resources:
repositories:
- repository: self
type: git
ref: refs/heads/sprint17
jobs:
- job: Job_1
displayName: Agent job 1
timeoutInMinutes: 120
pool:
vmImage: macos-latest
steps:
- checkout: self
fetchDepth: 1
- task: Npm@1
displayName: npm custom
inputs:
command: custom
verbose: false
customCommand: install --lts
- task: PowerShell@2
displayName: PowerShell Script
enabled: False
inputs:
targetType: inline
script: >
npm install
workingDirectory: .
- task: SonarSource.sonarcloud.****-c1da-4d55-aa01-****01255.SonarCloudPrepare@1
displayName: Prepare analysis on SonarCloud
inputs:
SonarCloud: 10***0e-******-8583-4****04b5ab
organization: beta-1
scannerMode: CLI
configMode: manual
cliProjectKey: beta1-Frontend
cliProjectName: beta-1-Frontend
extraProperties: "# Additional properties that will be passed to the scanner, \n# Put one key=value per line, example:\n #sonar.exclusions=**/*.bin\nsonar.exclusions=public/mockServiceWorker.js,**/__tests__/*, **/*.test.*\nsonar.test.exclusions=**/__tests__/*,*.test.*\nsonar.javascript.lcov.reportPaths=./coverage/lcov.info\n#sonar.scm.disabled=true\n\n"
- task: Npm@1
displayName: npm custom
enabled: False
inputs:
command: custom
verbose: false
customCommand: build
- task: CmdLine@2
displayName: Command Line Script
enabled: False
inputs:
script: "npm test \n"
- task: PowerShell@2
displayName: PowerShell Script
enabled: False
inputs:
targetType: inline
script: npm test
workingDirectory: src
- task: Npm@0
displayName: npm test
timeoutInMinutes: 120
inputs:
command: test
- task: SonarSource.sonarcloud.ce0***-6155-4de8-8800-422***a1.SonarCloudAnalyze@1
displayName: Run Code Analysis
inputs:
jdkversion: JAVA_HOME_21_X64
- task: Npm@1
displayName: npm custom
enabled: False
inputs:
command: custom
verbose: false
- task: SonarSource.sonarcloud.38b***9-a642-40af-bb7d-*****12e8.SonarCloudPublish@1
displayName: Publish Quality Gate Result
Thanks. I’m still stumped. The docs say that NodeJS 18.20.3 should be used.
Can you run a simple node -v
command in your pipeline and report the results?
It is showing 18.20.3
Generating script.
Script contents:
node -v
========================== Starting Command Output ===========================
/bin/bash --noprofile --norc /Users/runner/work/_temp/31db397a-e5e7-4dbb-ac3e-c086eb5bc1a6.sh
v18.20.3
That’s even weirder.
Could you please add sonar.verbose=true
as an analysis parameter, and find the logs that look like this in the Run Code Analysis step and share them?
15:03:40.371 DEBUG: Looking for Node.js in the PATH using run-node (macOS)
15:03:40.372 DEBUG: Using default Node.js executable: '/Users/colin/source/commonroom-scripts/.scannerwork/.sonartmp/eslint-bridge-bundle/package/node_modules/run-node/run-node'.
15:03:40.372 DEBUG: Checking Node.js version
15:03:40.372 DEBUG: Launching command /Users/colin/source/commonroom-scripts/.scannerwork/.sonartmp/eslint-bridge-bundle/package/node_modules/run-node/run-node -v
15:03:40.573 DEBUG: Using Node.js v22.2.0.
Hi, Please find the output:
05:43:11.855 DEBUG Looking for Node.js in the PATH using run-node (macOS)
05:43:11.856 INFO Using Node.js executable: '/Users/runner/work/1/s/.scannerwork/.sonartmp/bridge-bundle/package/node_modules/run-node/run-node'.
05:43:11.856 DEBUG Checking Node.js version
05:43:11.856 DEBUG Launching command /Users/runner/work/1/s/.scannerwork/.sonartmp/bridge-bundle/package/node_modules/run-node/run-node -v
##[error]05:43:11.892 ERROR Unsupported Node.JS version detected 18.12.1. Please upgrade to the latest Node.JS LTS version.
org.sonar.plugins.javascript.nodejs.NodeCommandException: Unsupported Node.JS version detected 18.12.1. Please upgrade to the latest Node.JS LTS version.
at org.sonar.plugins.javascript.nodejs.NodeCommandBuilderImpl.checkNodeCompatibility(NodeCommandBuilderImpl.java:184)
hi @fabin-b ,
it seems that somehow we are picking some strange version from the environment. On macos we use run-node
to find the right binary, but for some reason it doesn’t work in your case.
Could you pls try to use sonar.nodejs.executable
property set to the full path to the right node? (if you don’t know where is node, try to run which node
)
Also, perhaps I would check and remove any irrelevant node installation from the image.
Seems sonar.nodejs.executable done the work. The pipeline run successfully.