SonarQube for IDE Setup
1. Install SonarLint or SonarQube for IDE
- Open VSCode.
- Go to the Extensions view (Ctrl+Shift+X or Cmd+Shift+X on macOS).
- Search for SonarLint or SonarQube for IDE and click Install.
2. Address Node.js Runtime Error
If you encounter the following error:
SonarQube for VSCode failed to analyze the JSON code: Node.js runtime version 18.17.0 or later is required.
Follow the steps below:
3. Find the Node.js Path
On macOS/Linux:
which node
On Windows:
where node
4. Ensure VSCode Uses the Correct Node.js Runtime
- Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P on macOS).
- Search for Preferences: Open User Settings (JSON) and select it.
- Add or update the Node.js path setting:
{ "sonarlint.nodePath": "/absolute/path/to/your/node" }
Replace /absolute/path/to/your/node
with the actual Node.js binary path found in step 3.
5. Save and Restart VSCode
- Save the updated User Settings (JSON) file.
- Restart VSCode to apply the changes.
6. Re-run SonarLint or SonarQube
Trigger the code analysis again to confirm that the correct Node.js runtime is now being used.