Sonar-scanner 3.1.0 getting error Unexpected token . in angular 8

i am work on angular 8 project and node version is 10.24.0
in package.json file i am using “sonar-scanner”: “^3.1.0”
while deploying code on staging server using docker
i am getting below error:


2023-02-27T08:48:51.1148097Z ##[section]Starting: Bash
2023-02-27T08:48:51.1156048Z ==============================================================================
2023-02-27T08:48:51.1156409Z Task         : Bash
2023-02-27T08:48:51.1156684Z Description  : Run a Bash script on macOS, Linux, or Windows
2023-02-27T08:48:51.1156988Z Version      : 3.214.0
2023-02-27T08:48:51.1157221Z Author       : Microsoft Corporation
2023-02-27T08:48:51.1157585Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/bash
2023-02-27T08:48:51.1158021Z ==============================================================================
2023-02-27T08:48:51.2544054Z Generating script.
2023-02-27T08:48:51.2568771Z ========================== Starting Command Output ===========================
2023-02-27T08:48:51.2581191Z [command]/usr/bin/bash /azp/_work/_temp/398b6c2c-745f-4d11-9eb6-612571d52a78.sh
2023-02-27T08:50:02.6538534Z npm WARN notsup Unsupported engine for sonarqube-scanner@3.0.1: wanted: {"node":">= 14"} (current: {"node":"10.24.1","npm":"6.14.12"})
2023-02-27T08:50:02.6547094Z npm WARN notsup Not compatible with your version of node/npm: sonarqube-scanner@3.0.1
2023-02-27T08:50:02.6548809Z npm WARN notsup Unsupported engine for node-downloader-helper@2.1.6: wanted: {"node":">=14.18"} (current: {"node":"10.24.1","npm":"6.14.12"})
2023-02-27T08:50:02.6550888Z npm WARN notsup Not compatible with your version of node/npm: node-downloader-helper@2.1.6
2023-02-27T08:50:02.6556113Z npm WARN @ngrx/core@1.2.0 requires a peer of rxjs@^5.0.0-beta.12 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6570465Z npm WARN @ngrx/effects@7.4.0 requires a peer of @angular/core@^7.0.0 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6597951Z npm WARN @ngrx/router-store@7.4.0 requires a peer of @angular/common@^7.0.0 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6611311Z npm WARN @ngrx/router-store@7.4.0 requires a peer of @angular/core@^7.0.0 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6629877Z npm WARN @ngrx/router-store@7.4.0 requires a peer of @angular/router@^7.0.0 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6641748Z npm WARN @ngrx/store@7.4.0 requires a peer of @angular/core@^7.0.0 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6657175Z npm WARN bootstrap@4.3.1 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6677649Z npm WARN bootstrap@4.3.1 requires a peer of popper.js@^1.14.7 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6709847Z npm WARN microsoft-adal-angular6@1.3.0 requires a peer of @angular/common@^6.0.0-rc.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6736991Z npm WARN microsoft-adal-angular6@1.3.0 requires a peer of @angular/core@^6.0.0-rc.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6755095Z npm WARN ngx-bar-rating@2.0.0 requires a peer of @angular/common@^10.1.3 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6778043Z npm WARN ngx-bar-rating@2.0.0 requires a peer of @angular/core@^10.1.3 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6796040Z npm WARN ngx-barcode@0.2.4 requires a peer of @angular/core@^4.0.0 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6816703Z npm WARN ngx-barcode@0.2.4 requires a peer of rxjs@^5.1.0 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6847842Z npm WARN ngx-barcode@0.2.4 requires a peer of zone.js@^0.8.4 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6870059Z npm WARN ngx-qrcode2@0.0.9 requires a peer of @angular/core@^6.0.3 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6892157Z npm WARN ngx-qrcode2@0.0.9 requires a peer of zone.js@^0.8.26 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6922465Z npm WARN tsickle@0.36.0 requires a peer of typescript@~3.4.1 but none is installed. You must install peer dependencies yourself.
2023-02-27T08:50:02.6925268Z 
2023-02-27T08:50:02.6949690Z + sonarqube-scanner@3.0.1
2023-02-27T08:50:03.7112243Z updated 1 package and audited 1664 packages in 70.883s
2023-02-27T08:50:03.7113407Z found 324 vulnerabilities (11 low, 100 moderate, 170 high, 43 critical)
2023-02-27T08:50:03.7114322Z   run `npm audit fix` to fix them, or `npm audit` for details
2023-02-27T08:50:04.0189130Z 
2023-02-27T08:50:04.0190709Z > pwm-ui@0.0.0 sonar /azp/_work/1/s
2023-02-27T08:50:04.0191371Z > node sonar-project.js
2023-02-27T08:50:04.0192759Z 
2023-02-27T08:50:04.1198895Z /azp/_work/1/s/node_modules/sonarqube-scanner/src/sonar-scanner-params.js:152
2023-02-27T08:50:04.1200059Z     if (pkg.bugs?.url) {
2023-02-27T08:50:04.1200752Z                  ^
2023-02-27T08:50:04.1201321Z 
2023-02-27T08:50:04.1202209Z SyntaxError: Unexpected token .
2023-02-27T08:50:04.1202906Z     at Module._compile (internal/modules/cjs/loader.js:723:23)
2023-02-27T08:50:04.1203687Z     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
2023-02-27T08:50:04.1217247Z     at Module.load (internal/modules/cjs/loader.js:653:32)
2023-02-27T08:50:04.1222057Z     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2023-02-27T08:50:04.1223225Z     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2023-02-27T08:50:04.1223753Z     at Module.require (internal/modules/cjs/loader.js:692:17)
2023-02-27T08:50:04.1224259Z     at require (internal/modules/cjs/helpers.js:25:18)
2023-02-27T08:50:04.1225406Z     at Object.<anonymous> (/azp/_work/1/s/node_modules/sonarqube-scanner/src/config.js:20:28)
2023-02-27T08:50:04.1226006Z     at Module._compile (internal/modules/cjs/loader.js:778:30)
2023-02-27T08:50:04.1226589Z     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
2023-02-27T08:50:04.1274666Z npm ERR! code ELIFECYCLE
2023-02-27T08:50:04.1277931Z npm ERR! errno 1
2023-02-27T08:50:04.1294368Z npm ERR! pwm-ui@0.0.0 sonar: `node sonar-project.js`
2023-02-27T08:50:04.1295019Z npm ERR! Exit status 1
2023-02-27T08:50:04.1295344Z npm ERR! 
2023-02-27T08:50:04.1295945Z npm ERR! Failed at the pwm-ui@0.0.0 sonar script.
2023-02-27T08:50:04.1296478Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2023-02-27T08:50:04.1428919Z 
2023-02-27T08:50:04.1429672Z npm ERR! A complete log of this run can be found in:
2023-02-27T08:50:04.1431174Z npm ERR!     /root/.npm/_logs/2023-02-27T08_50_04_129Z-debug.log
2023-02-27T08:50:04.1567915Z ##[error]Bash exited with code '1'.
2023-02-27T08:50:04.1601778Z ##[section]Finishing: Bash```
----------------------------------------------------
can someone help to resolve this issue

#sq #sonaranalysis

Hey there.

As noted here

Prerequisite: Node v14+ (otherwise use sonarqube-scanner v2.9.1)

@Colin Thank you for this solution.
I have downgraded the Sonar Scanner/SonarQube version, and it fixed the above issue.
(this is previous => “sonar-scanner”: “^3.1.0”, updated version => “sonarqube-scanner”: “^2.9.1”)

could you plz tell me why stop supporting “sonar-scanner”: “^3.1.0” version for nodejs 10.24.0

The analysis of Javascript/Typescript code requires NodeJS 14 as of SonarQube 9.9 LTS – so that has been applied to the npm scanner as well. Read more in the documentation on Scanner environment

Thank you

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.