The base directory of the module does not exist SonarScanner.MSBuild.exe failed with exit code 1

Running a SonarCloudAnalyze in AzureDevops for MSBuild. I’m getting an error where it cannot find a module in node_modules directory even though node_modules is mentioned in sonar.exclusions.
Tried to include specific CSharp folders and still showing same results.

  • ALM used: Azure DevOps

  • CI system used: Azure DevOps

  • Scanner command used when applicable (private details masked)

      - task: SonarCloudPrepare@1
        displayName: 'Prepare Sonar Cloud CSharp'
        inputs:
          SonarCloud: 'SonarCloud'
          organization: 'SonarCloud-org'
          scannerMode: 'MSBuild'
          projectKey: 'SonarCloud-org_Project1_CSharp' 
          projectName: 'Project1_CSharp'
          extraProperties: |
            sonar.verbose=true
            sonar.exclusions=**/Automation/**,**/Terraform/**,**/Tools/**,**/Help/**,**/Installer/**,**/DevBuild/**,**/Install/**,**/node_modules/**
            sonar.test.inclusions=**/Dir1.Tests/**,**/Dir2.Tests/**,**/Dir3.Tests/**,**/Dir4.Tests/**
            sonar.coverageReportPaths=$(Build.SourcesDirectory)/coverlet/reports/netcore/SonarQube.xml
    
    - task: NodeTool@0
      displayName: 'Install node tool'
      inputs:
        versionSpec: '14.21.3'
    
    - task: DotNetCoreCLI@2
      displayName: 'Dotnet restore'
      inputs:
        command: 'restore'
        projects: '**/*.sln'
        feedsToUse: 'select'
        vstsFeed: ...
    
    - task: Npm@1
      displayName: 'NPM Install node_modules from Artifact feed'
      inputs:
        command: 'ci'
        workingDir: 'APP/WebApp/ClientApp'
        customRegistry: 'useFeed'
        customFeed: ...
    
    - task: VSBuild@1
      displayName: 'VSBuild Application'
      inputs:
        solution: '**/App.sln'
    
      - task: reportgenerator@5
        displayName: 'Generate Cobertura Report for .Net Core'
        inputs:
          reports: '$(Agent.TempDirectory)/**/coverage.cobertura.xml'
          targetdir: '$(Build.SourcesDirectory)/coverlet/reports/netcore'
          reporttypes: 'HtmlInline_AzurePipelines;Cobertura;SonarQube'
          classfilters: '$(classes-to-exclude-from-coverage)'
    
      - task: SonarCloudAnalyze@1
        displayName: 'Run SonarCloud Code Analysis for CSharp'
        inputs:
          jdkversion: 'JAVA_HOME_21_X64'
          extraProperties: |
            sonar.verbose=true
    
      - task: SonarCloudPublish@1
        displayName: 'Publish SonarCloud Quality Gate Result for CSharp'
        inputs:
          pollingTimeoutSec: '300'
    
    
  • Languages of the repository: CSharp, TypeScript

  • SonarCloud project is not public

  • Error observed:

1. ##[error]13:08:16.653 ERROR: Error during SonarScanner execution

13:08:16.653 ERROR: Error during SonarScanner execution

##[error]java.lang.IllegalStateException: The base directory of the module '756F6D64-1B74-8F31-0AD3-5DF83A6F53FA' does not exist: $(build.sourcesDirectory)\APP\WebApp\ClientApp\node_modules\nice-napi\node-addon-api

java.lang.IllegalStateException: The base directory of the module '756F6D64-1B74-8F31-0AD3-5DF83A6F53FA' does not exist: $(build.sourcesDirectory)\APP\WebApp\ClientApp\node_modules\nice-napi\node-addon-api

##[error]at org.sonarsource.scanner.cli.Conf.setModuleBaseDir(Conf.java:195)

at org.sonarsource.scanner.cli.Conf.setModuleBaseDir(Conf.java:195)

##[error]at org.sonarsource.scanner.cli.Conf.loadModuleConfigFile(Conf.java:174)

at org.sonarsource.scanner.cli.Conf.loadModuleConfigFile(Conf.java:174)

##[error]at org.sonarsource.scanner.cli.Conf.loadModulesProperties(Conf.java:152)

at org.sonarsource.scanner.cli.Conf.loadModulesProperties(Conf.java:152)

##[error]at org.sonarsource.scanner.cli.Conf.loadProjectProperties(Conf.java:126)

at org.sonarsource.scanner.cli.Conf.loadProjectProperties(Conf.java:126)

##[error]at org.sonarsource.scanner.cli.Conf.properties(Conf.java:60)

at org.sonarsource.scanner.cli.Conf.properties(Conf.java:60)

##[error]at org.sonarsource.scanner.cli.Main.execute(Main.java:70)

at org.sonarsource.scanner.cli.Main.execute(Main.java:70)

##[error]at org.sonarsource.scanner.cli.Main.main(Main.java:62)

at org.sonarsource.scanner.cli.Main.main(Main.java:62)

Process returned exit code 1

##[error]The SonarScanner did not complete successfully

The SonarScanner did not complete successfully

##[error]13:08:16.7 Post-processing failed. Exit code: 1

13:08:16.7 Post-processing failed. Exit code: 1

##[error]The process 'D:\P2\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1

Finishing: Run SonarCloud Code Analysis for CSharp
  • Steps to reproduce: Just run the pipeline
  • Potential workaround: none of them helped

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Hey there.

That’s pretty odd - have you set any explicit inclusions or other settings in the .csproj files that make up your solution?