Vue js project sonar scanner gives Axios Error with status code 401 - Scanner version 4.2.8

I am running a sonar scan for a front end Vue js project and it gives me Axios Error with status code 401.

I do have other projects in C# .net which do not give the same error. Can someone please help me on this?

Hey there.

Can you share the full logs where you experience this issue, and give some more details about the environment you’re running analysis in? Locally? In a CI environment?

Thanks Colin.

I am running it locally on my VS Code IDE, with the token generated from the sonarcloud.

The log is below:

sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=**********************
[INFO]  Bootstrapper: Retrieving info from "package.json" file
[INFO]  Bootstrapper: Platform: win32 x64
[INFO]  Bootstrapper: Server URL: https://sonarcloud.io
[INFO]  Bootstrapper: Version: 4.2.8
[INFO]  Bootstrapper: JRE provisioning is supported
[ERROR] Bootstrapper: An error occurred: AxiosError: Request failed with status code 401

Alternatively this morning I used the below command

(Setting the token)

$env:SONAR_TOKEN="your-sonar-token"

(And then run the command below):

sonar-scanner

Gave me this error below:

[INFO]  Bootstrapper: Retrieving info from "package.json" file
[INFO]  Bootstrapper: Platform: win32 x64
[INFO]  Bootstrapper: Server URL: https://sonarcloud.io
[INFO]  Bootstrapper: Version: 4.2.8
[INFO]  Bootstrapper: JRE provisioning is supported
[INFO]  Bootstrapper: Using JRE from the cache
[INFO]  Bootstrapper: No Cache found for SonarScanner Engine
[INFO]  Bootstrapper: Download starting...
[INFO]  Bootstrapper: Download complete
[INFO]  Bootstrapper: Downloaded SonarScanner Engine to C:\Users\aparna.sekar\.sonar\cache\4c3f2790c7699f6a0131413c0043f7bad87472607321fa0af2255d5193f3f0df\sonarcloud-scanner-engine-11.5.0.358.jar 
node:events:485
      throw er; // Unhandled 'error' event
      ^

[INFO]  Bootstrapper: Downloaded SonarScanner Engine to C:\Users\aparna.sekar\.sonar\cache\4c3f2790c7699f6a0131413c0043f7bad87472607321fa0af2255d5193f3f0df\sonarcloud-scanner-engine-11.5.0.358.jar 
node:events:485
      throw er; // Unhandled 'error' event
      ^

node:events:485
      throw er; // Unhandled 'error' event
      ^

      throw er; // Unhandled 'error' event
      ^

      ^


Error: spawn C:\Users\aparna.sekar\.sonar\cache\4bafe2e94439c8193fc8c68247cb0dbaf4e80265b903288f63f128304f129bbe\OpenJDK17U-jre_x64_windows_hotspot_17.0.11_9.zip_unzip\jdk-17.0.11+9-jre\bin\java.exError: spawn C:\Users\aparna.sekar\.sonar\cache\4bafe2e94439c8193fc8c68247cb0dbaf4e80265b903288f63f128304f129bbe\OpenJDK17U-jre_x64_windows_hotspot_17.0.11_9.zip_unzip\jdk-17.0.11+9-jre\bin\java.exe ENOENT
e ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
Emitted 'error' event on ChildProcess instance at:
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
Emitted 'error' event on ChildProcess instance at:
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\\Users\\aparna.sekar\\.sonar\\cache\\4bafe2e94439c8193fc8c68247cb0dbaf4e80265b903288f63f128304f129bbe\\OpenJDK17U-jre_x64_windows_hotspot_17.0.11_9.zip_unzip\\jdk-17.0.11+9-jre\\bin\\java.exe',
  path: 'C:\\Users\\aparna.sekar\\.sonar\\cache\\4bafe2e94439c8193fc8c68247cb0dbaf4e80265b903288f63f128304f129bbe\\OpenJDK17U-jre_x64_windows_hotspot_17.0.11_9.zip_unzip\\jdk-17.0.11+9-jre\\bin\\java.exe',
  spawnargs: [
    '-jar',
    'C:\\Users\\aparna.sekar\\.sonar\\cache\\4c3f2790c7699f6a0131413c0043f7bad87472607321fa0af2255d5193f3f0df\\sonarcloud-scanner-engine-11.5.0.358.jar'
  ]
}