Issue with Node environment for Sonarlint

Please provide

  • Operating system: Mac OS 14
  • SonarLint plugin version: 4.2.2
  • Programming language you’re coding in: Python
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version): No

And a thorough description of the problem / question:
I had installed Sonarlint on both my Mac and my windows and the settings were being synced. The initial installation was windows so the Node executable path was set as windows path. Now, I don’t have access to my windows laptop and disabled the sync. However, the node path is still being set as the windows and does not pick the new Mac path I enter. Have a node version 20+ installed but VS code says sonarlint was unable to check JSON…

here’s the actual error screenshot and the setting:
Screenshot 2023-12-22 at 2.05.38 PM


Screenshot 2023-12-22 at 2.06.12 PM

Hey there.

Is there anything special about this distribution of VS Code? A user recently shared an issue where their VS Code distribution couldn’t “see” the /usr/bin/node. Take a look at this thread:

Hi Colin,

I’m not aware about flatpak. Mine is a downloaded version from the vs code website. When I had my windows laptop, I did not have the issue there but since the time I stopped using that, the path does not take into account the local machine’s path but the one synced with the Windows path. I have stopped all sync and updated like in the screenshot but nothing works.

Hello @Pranay_Suyash, welcome to Sonar Community! :sonar: :wave:

Apologies for the delay, you know how it gets during the end-of-year :slight_smile: :bowing_woman:

Off the top of my head, I cannot see any obvious reason why that is happening. The first and easiest thing you could try is to maybe uninstall and reinstall SonarLint on your Mac? If that still does not help, we would need SonarLint logs to investigate. You can find the instructions on how to get them here.

Thanks in advance,
Sophio from :sonarlint_vscode:

Hi Sophio,

A very happy New Year to you! I have already tried uninstalling the extension but that didn’t work either. I will try to get the logs and share them across.

Is there some update on this issue? Have exactly the same problem

@Kseniia_Dzhigun Feel free to share the logs that @sophio.japharidze requested earlier, but that @Pranay_Suyash didn’t come back wtih.

Hello Colin,
I updated my VS Code to the latest version using the official .DMG file from Microsoft themselves.

I am using ‘nvm’ to manage my Node versions to make things more sane instead of having to install individual versions of Node that conflict.

Here is what I am using for the ’ Sonarlint: Path To Node Executable’ setting in VS Code in MacOS:

/home/sbanya/.nvm/versions/node/v18.17.0/bin/node

Here’s the output of ‘nvm’:

sbanya@macboook-osm-sbanya ~/.nvm/versions/node/v18.17.0/bin $ pwd
/Users/sbanya/.nvm/versions/node/v18.17.0/bin

sbanya@macboook-osm-sbanya ~/.nvm/versions/node/v18.17.0/bin $ nvm --version
0.39.3

sbanya@macboook-osm-sbanya ~/.nvm/versions/node/v18.17.0/bin $ nvm alias default v18.17.0

sbanya@macboook-osm-sbanya ~/.nvm/versions/node/v18.17.0/bin $ node --version
v18.17.0

I am running into the same exact issue as mentioned above in which Sonarlint fails with this message:

SonarLint failed to analyze TypeScript code: Node.js runtime version 16.0.0 or later is required.

Here is the corresponding debug output requested earlier as I am using an M1 Macbook running MacOS Sonoma Version 14.3.1

Executing /Users/sbanya/.vscode/extensions/sonarsource.sonarlint-vscode-4.3.0-darwin-arm64/jre/21.0.2-macosx-aarch64.tar/bin/java -jar /Users/sbanya/.vscode/extensions/sonarsource.sonarlint-vscode-4.3.0-darwin-arm64/server/sonarlint-ls.jar -stdio -analyzers /Users/sbanya/.vscode/extensions/sonarsource.sonarlint-vscode-4.3.0-darwin-arm64/analyzers/sonargo.jar /Users/sbanya/.vscode/extensions/sonarsource.sonarlint-vscode-4.3.0-darwin-arm64/analyzers/sonarjava.jar /Users/sbanya/.vscode/extensions/sonarsource.sonarlint-vscode-4.3.0-darwin-arm64/analyzers/sonarjs.jar /Users/sbanya/.vscode/extensions/sonarsource.sonarlint-vscode-4.3.0-darwin-arm64/analyzers/sonarphp.jar /Users/sbanya/.vscode/extensions/sonarsource.sonarlint-vscode-4.3.0-darwin-arm64/analyzers/sonarpython.jar /Users/sbanya/.vscode/extensions/sonarsource.sonarlint-vscode-4.3.0-darwin-arm64/analyzers/sonarhtml.jar /Users/sbanya/.vscode/extensions/sonarsource.sonarlint-vscode-4.3.0-darwin-arm64/analyzers/sonarxml.jar /Users/sbanya/.vscode/extensions/sonarsource.sonarlint-vscode-4.3.0-darwin-arm64/analyzers/sonarcfamily.jar /Users/sbanya/.vscode/extensions/sonarsource.sonarlint-vscode-4.3.0-darwin-arm64/analyzers/sonartext.jar /Users/sbanya/.vscode/extensions/sonarsource.sonarlint-vscode-4.3.0-darwin-arm64/analyzers/sonariac.jar /Users/sbanya/.vscode/extensions/sonarsource.sonarlint-vscode-4.3.0-darwin-arm64/analyzers/sonarlintomnisharp.jar
[stderr] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[stderr] SLF4J: Defaulting to no-operation (NOP) logger implementation
[stderr] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[Debug - 07:47:51.472] Fetching global configuration
[Debug - 07:47:51.507] Queuing analysis of file "file:///Users/sbanya/hub/repos/opti-ui/src/components/VerticalStepper/TravelerDetails/TravelerDetails.tsx" (version 1)
[Debug - 07:47:51.541] Queuing analysis of file "file:///Users/sbanya/hub/repos/opti-ui/src/components/Buttons/OptiIconButton.tsx" (version 1)
No submodules found in '/Users/sbanya/hub/repos/opti-ui' repository. Error: 
Error when detecting ignored files: 
[Debug - 07:47:51.822] Cached SCM ignore status for file "file:///Users/sbanya/hub/repos/opti-ui/src/components/VerticalStepper/TravelerDetails/TravelerDetails.tsx": Not ignored
[Debug - 07:48:23.401] Fetching configuration for folder 'file:///Users/sbanya/hub/repos/opti-ui'
[Debug - 07:48:23.404] Workspace folder 'WorkspaceFolder[name=opti-ui,uri=file:///Users/sbanya/hub/repos/opti-ui]' configuration updated: WorkspaceFolderSettings[analyzerProperties={sonar.cs.file.suffixes=.cs, sonar.cs.internal.useNet6=true, sonar.cs.internal.loadProjectOnDemand=false, sonar.cs.internal.loadProjectsTimeout=60},connectionId=<null>,pathToCompileCommands=,projectKey=<null>,testFilePattern=]
[Debug - 07:48:23.405] Global settings updated: WorkspaceSettings[connections={},disableTelemetry=false,excludedRules=[],focusOnNewCode=false,includedRules=[],pathToNodeExecutable=/home/sbanya/.nvm/versions/node/v18.17.0/bin/node,ruleParameters={},showAnalyzerLogs=true,showVerboseLogs=true]
[Info  - 07:48:23.405] Analyzing file "file:///Users/sbanya/hub/repos/opti-ui/src/components/VerticalStepper/TravelerDetails/TravelerDetails.tsx"...
[Debug - 07:48:23.408] Default settings updated: WorkspaceFolderSettings[analyzerProperties={sonar.cs.file.suffixes=.cs, sonar.cs.internal.useNet6=true, sonar.cs.internal.loadProjectOnDemand=false, sonar.cs.internal.loadProjectsTimeout=60},connectionId=<null>,pathToCompileCommands=,projectKey=<null>,testFilePattern=]
[Debug - 07:48:23.409] Analysis triggered with configuration:
[
  baseDir: /Users/sbanya/hub/repos/opti-ui
  extraProperties: {sonar.cs.file.suffixes=.cs, sonar.cs.internal.loadProjectsTimeout=60, sonar.cfamily.compile-commands=, sonar.cs.internal.useNet6=true, sonar.cs.internal.loadProjectOnDemand=false}
  moduleKey: file:///Users/sbanya/hub/repos/opti-ui
  excludedRules: []
  includedRules: []
  ruleParameters: {}
  inputFiles: [
    file:///Users/sbanya/hub/repos/opti-ui/src/components/VerticalStepper/TravelerDetails/TravelerDetails.tsx (UTF-8) [ts]
  ]
]

[Debug - 07:48:23.409] Starting standalone SonarLint engine...
[Debug - 07:48:23.409] Using 11 analyzers
[Debug - 07:48:23.481] Plugin 'JavaScript/TypeScript/CSS Code Quality and Security' requires Node.js 16.0.0. Skip loading it.
[Debug - 07:48:23.491] Loaded 10 plugins
[Debug - 07:48:23.491]   * CFamily Code Quality and Security 6.52.0.66181 (cpp)
[Debug - 07:48:23.491]   * Python Code Quality and Security 4.14.0.14263 (python)
[Debug - 07:48:23.491]   * C# Code Quality and Security (Omnisharp) 1.17.0.82356 (csharp)
[Debug - 07:48:23.491]   * Java Code Quality and Security 7.30.1.34514 (java)
[Debug - 07:48:23.491]   * HTML Code Quality and Security 3.13.0.4821 (web)
[Debug - 07:48:23.491]   * XML Code Quality and Security 2.10.0.4108 (xml)
[Debug - 07:48:23.491]   * Go Code Quality and Security 1.15.0.4655 (go)
[Debug - 07:48:23.491]   * PHP Code Quality and Security 3.33.0.11274 (php)
[Debug - 07:48:23.491]   * IaC Code Quality and Security 1.26.0.8471 (iac)
[Debug - 07:48:23.491]   * Text Code Quality and Security 2.8.0.1635 (text)
[Debug - 07:48:24.495] Creating container for module 'file:///Users/sbanya/hub/repos/opti-ui'
[Debug - 07:48:24.508] Standalone SonarLint engine started
[Debug - 07:48:24.560] Start analysis
[Info  - 07:48:24.574] Index files
[Debug - 07:48:24.575] Language of file "file:///Users/sbanya/hub/repos/opti-ui/src/components/VerticalStepper/TravelerDetails/TravelerDetails.tsx" is set to "TypeScript"
[Info  - 07:48:24.576] 1 file indexed
[Debug - 07:48:24.865] 'JavaSensor' skipped because there is no related files in the current project
[Debug - 07:48:24.866] 'OmniSharp' skipped because there is no related files in the current project
[Debug - 07:48:24.866] 'Python Sensor' skipped because there is no related files in the current project
[Debug - 07:48:24.866] 'IPython Notebooks Sensor' skipped because there is no related files in the current project
[Debug - 07:48:24.866] Execute Sensor: HTML
[Debug - 07:48:24.867] 'XML Sensor' skipped because there is no related files in the current project
[Debug - 07:48:24.867] 'Code Quality and Security for Go' skipped because there is no related files in the current project
[Debug - 07:48:24.867] 'PHP sensor' skipped because there is no related files in the current project
[Debug - 07:48:24.867] 'Analyzer for "php.ini" files' skipped because there is no related files in the current project
[Debug - 07:48:24.867] 'IaC Terraform Sensor' skipped because there is no related files in the current project
[Debug - 07:48:24.867] 'IaC CloudFormation Sensor' skipped because there is no related files in the current project
[Debug - 07:48:24.867] 'IaC Kubernetes Sensor' skipped because there is no related files in the current project
[Debug - 07:48:24.867] 'IaC AzureResourceManager Sensor' skipped because there is no related files in the current project
[Debug - 07:48:24.868] Execute Sensor: TextAndSecretsSensor
[Info  - 07:48:25.076] 1 source file to be analyzed
[Info  - 07:48:25.130] 1/1 source file has been analyzed
[Debug - 07:48:25.130] Execute Sensor: IaC Docker Sensor
[Info  - 07:48:25.132] 0 source files to be analyzed
[Info  - 07:48:25.163] 0/0 source files have been analyzed
[Debug - 07:48:25.163] 'CFamily' skipped because there is no related files in the current project
[Warn  - 07:48:25.165] Node.js runtime version 16.0.0 or later is required.
[Info  - 07:48:25.173] Found 0 issues
No submodules found in '/Users/sbanya/hub/repos/opti-ui' repository. Error: 
Error when detecting ignored files: 
[Debug - 07:48:25.236] Cached SCM ignore status for file "file:///Users/sbanya/hub/repos/opti-ui/src/components/Buttons/OptiIconButton.tsx": Not ignored
[Info  - 07:48:25.236] Analyzing file "file:///Users/sbanya/hub/repos/opti-ui/src/components/Buttons/OptiIconButton.tsx"...
[Debug - 07:48:25.236] Analysis triggered with configuration:
[
  baseDir: /Users/sbanya/hub/repos/opti-ui
  extraProperties: {sonar.cs.file.suffixes=.cs, sonar.cs.internal.loadProjectsTimeout=60, sonar.cfamily.compile-commands=, sonar.cs.internal.useNet6=true, sonar.cs.internal.loadProjectOnDemand=false}
  moduleKey: file:///Users/sbanya/hub/repos/opti-ui
  excludedRules: []
  includedRules: []
  ruleParameters: {}
  inputFiles: [
    file:///Users/sbanya/hub/repos/opti-ui/src/components/Buttons/OptiIconButton.tsx (UTF-8) [ts]
  ]
]

[Debug - 07:48:25.249] Start analysis
[Info  - 07:48:25.252] Index files
[Debug - 07:48:25.252] Language of file "file:///Users/sbanya/hub/repos/opti-ui/src/components/Buttons/OptiIconButton.tsx" is set to "TypeScript"
[Info  - 07:48:25.253] 1 file indexed
[Debug - 07:48:25.283] 'JavaSensor' skipped because there is no related files in the current project
[Debug - 07:48:25.283] 'OmniSharp' skipped because there is no related files in the current project
[Debug - 07:48:25.284] 'Python Sensor' skipped because there is no related files in the current project
[Debug - 07:48:25.284] 'IPython Notebooks Sensor' skipped because there is no related files in the current project
[Debug - 07:48:25.284] Execute Sensor: HTML
[Debug - 07:48:25.284] 'XML Sensor' skipped because there is no related files in the current project
[Debug - 07:48:25.284] 'Code Quality and Security for Go' skipped because there is no related files in the current project
[Debug - 07:48:25.284] 'PHP sensor' skipped because there is no related files in the current project
[Debug - 07:48:25.284] 'Analyzer for "php.ini" files' skipped because there is no related files in the current project
[Debug - 07:48:25.284] 'IaC Terraform Sensor' skipped because there is no related files in the current project
[Debug - 07:48:25.284] 'IaC CloudFormation Sensor' skipped because there is no related files in the current project
[Debug - 07:48:25.284] 'IaC Kubernetes Sensor' skipped because there is no related files in the current project
[Debug - 07:48:25.284] 'IaC AzureResourceManager Sensor' skipped because there is no related files in the current project
[Debug - 07:48:25.284] Execute Sensor: TextAndSecretsSensor
[Info  - 07:48:25.310] 1 source file to be analyzed
[Info  - 07:48:25.315] 1/1 source file has been analyzed
[Debug - 07:48:25.315] Execute Sensor: IaC Docker Sensor
[Info  - 07:48:25.316] 0 source files to be analyzed
[Info  - 07:48:25.320] 0/0 source files have been analyzed
[Debug - 07:48:25.321] 'CFamily' skipped because there is no related files in the current project
[Warn  - 07:48:25.321] Node.js runtime version 16.0.0 or later is required.
[Info  - 07:48:25.330] Found 0 issues

Next Steps:
Is there any timeline when this issue will be fixed? Thanks!

Hello :wave: in this particular case, SonarLint does not seem able to automatically detect the runtime installed by nvm.

It should be possible to circumvent this by explicitly setting it in your VSCode user settings, using the sonarlint.pathToNodeExecutable property. E.g.:

{
  "sonarlint.pathToNodeExecutable": "/Users/sbanya/.nvm/versions/node/v18.17.0/bin/node"
}

Unless this is a typo (or you have a symlink in your file system), I believe that /home/sbanya and /Users/sbanya are different folders :innocent:

1 Like

Sweet, thanks Jean-Baptiste, using the explicit ‘/users/(username)’ based path worked!

1 Like