Error when using scanner for npm

I get an error when executing sonar scanner for npm localy in vscode for a sonarqube cloud project:

sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.token=“my-sonar-token

[INFO] Bootstrapper: Retrieving info from “package.json” file
[INFO] Bootstrapper: Platform: win32 x64
[INFO] Bootstrapper: Server URL: https://sonarcloud.io
[INFO] Bootstrapper: Version: 4.3.0
[INFO] Bootstrapper: JRE provisioning is supported
[ERROR] Bootstrapper: An error occurred: AxiosError: Request failed with status code 401

I tried using a project token as well as a personal token. Same error.

Hi,

Welcome to the community!

Are you providing sonar.organization and sonar.projectKey to the analysis?

 
Thx,
Ann

Hi Ann,
thank you.
Initially I didnt. I tried now, but I get the same result.

Hi,

Can you remove any quotes from around your parameter values and try again?

 
Thx,
Ann

Hi Ann,
I didnt use any quotes with the parameter values, so nothing to remove :wink:
In the meantime I tried executing the scan in Visual Studio 2022 and it worked (sonar.organization and sonar.projectKey must provided).
So current status is: Using the same command in Visual Studio 2022 and VS Code. VS 2022 works, VS Code results in the 401 error.

Hi,

Are you using SonarQube for VSCode and getting the error from that? Or are you executing an analysis command directly from your IDE?

 
Ann

I am executing the command from the IDE.

Hi,

You’re pursing a use case we haven’t targeted. Analysis is meant to be run from a command line. The fact that you were able to get this working within Visual Studio (:face_with_raised_eyebrow:) suggests to me that the problem is specific to VSCode.

 
Ann