Global Typescript is used instead of local

Hello,
I got the same error on my CI/CD build server with Sonarqube 4.10.0.

##[error]ERROR: You are using version of TypeScript 2.7.2 which is not supported; supported versions >=3.2.1

My application uses typescript version 3.2.4 (package.json - “typescript”: “3.2.4”) but the globally installed version is 2.7.2.

How do I make Sonarqube analytics job to take the typescript version that the app is using instead of the globally installed version? In the Azure DevOps pipeline, I did issue an install task of ts v.3.2.4 before ‘npm build’ task and before ‘run code analysis’ task, but I still got the same error. So, your help is greatly appreciated.

Hey,

I moved your post to a new topic to have a cleaner discussion.
Could you share the logs of the analysis?

Basically analyzer looks for node_modules/typescript inside the project directory. Could you confirm you have one? If that one not found, standard NodeJS module resolution will be used.

Thank you for your reply, Elena. Yes, I do have that folder, and the version of the typescript is in the package.json

Please share the logs of analysis

Thank you for your response, Elena. Here is the log:

2020-06-11T21:37:43.4010804Z ##[section]Starting: Run Code Analysis
2020-06-11T21:37:43.4014936Z ==============================================================================
2020-06-11T21:37:43.4015044Z Task : Run Code Analysis
2020-06-11T21:37:43.4015105Z Description : Run scanner and upload the results to the SonarQube server.
2020-06-11T21:37:43.4015165Z Version : 4.10.0
2020-06-11T21:37:43.4015234Z Author : sonarsource
2020-06-11T21:37:43.4015304Z Help : Version: 4.10.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

More Information
2020-06-11T21:37:43.4015418Z ==============================================================================
2020-06-11T21:37:43.7994676Z [command]C:\Windows\system32\cmd.exe /D /S /C “D:\TFSBuild\azure_agent.2_work_tasks\SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055\4.10.0\sonar-scanner\bin\sonar-scanner.bat”
2020-06-11T21:37:44.0100856Z INFO: Scanner configuration file: D:\TFSBuild\azure_agent.2_work_tasks\SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055\4.10.0\sonar-scanner\bin…\conf\sonar-scanner.properties
2020-06-11T21:37:44.0112155Z INFO: Project root configuration file: NONE
2020-06-11T21:37:44.0325238Z INFO: SonarScanner 4.3.0.2102
2020-06-11T21:37:44.0325875Z INFO: Java 1.8.0_72 Oracle Corporation (64-bit)
2020-06-11T21:37:44.0326054Z INFO: Windows Server 2012 R2 6.3 amd64
2020-06-11T21:37:44.2384606Z INFO: User cache: C:\Users\Tfsbuildsrvacct.sonar\cache
2020-06-11T21:37:44.3871551Z INFO: Scanner configuration file: D:\TFSBuild\azure_agent.2_work_tasks\SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055\4.10.0\sonar-scanner\bin…\conf\sonar-scanner.properties
2020-06-11T21:37:44.3875320Z INFO: Project root configuration file: NONE
2020-06-11T21:37:44.3916004Z INFO: Analyzing on SonarQube server 8.3.1
2020-06-11T21:37:44.3920557Z INFO: Default locale: “en_US”, source code encoding: “UTF-8”
2020-06-11T21:37:44.5866458Z WARN: SonarScanner will require Java 11 to run starting in SonarQube 8.x
2020-06-11T21:37:44.6891534Z INFO: Load global settings
2020-06-11T21:37:44.7658933Z INFO: Load global settings (done) | time=78ms
2020-06-11T21:37:44.7681463Z INFO: Server id: 12345678 - XXXXXXXXXXXXXXXXXXXXXXX
2020-06-11T21:37:44.7718154Z INFO: User cache: C:\Users\Tfsbuildsrvacct.sonar\cache
2020-06-11T21:37:44.7748884Z INFO: Load/download plugins
2020-06-11T21:37:44.7749229Z INFO: Load plugins index
2020-06-11T21:37:44.8139669Z INFO: Load plugins index (done) | time=47ms
2020-06-11T21:37:44.8483353Z INFO: Load/download plugins (done) | time=80ms
2020-06-11T21:37:45.3713253Z INFO: Process project properties
2020-06-11T21:37:45.3795838Z INFO: Process project properties (done) | time=15ms
2020-06-11T21:37:45.3798007Z INFO: Execute project builders
2020-06-11T21:37:45.3840891Z INFO: Execute project builders (done) | time=0ms
2020-06-11T21:37:45.3895912Z INFO: Project key: sysdev-OLT-ui
2020-06-11T21:37:45.3896463Z INFO: Base dir: D:\TFSBuild\azure_agent.2_work\136\s
2020-06-11T21:37:45.3896614Z INFO: Working dir: D:\TFSBuild\azure_agent.2_work\136\s.scannerwork
2020-06-11T21:37:45.4594959Z INFO: Load project settings for component key: ‘sysdev-OLT-ui’
2020-06-11T21:37:45.4794323Z INFO: Load project settings for component key: ‘sysdev-OLT-ui’ (done) | time=15ms
2020-06-11T21:37:45.5548387Z INFO: Load quality profiles
2020-06-11T21:37:45.6060170Z INFO: Load quality profiles (done) | time=47ms
2020-06-11T21:37:45.6104243Z INFO: Auto-configuring with CI ‘Azure DevOps’
2020-06-11T21:37:45.6130140Z INFO: Load active rules
2020-06-11T21:37:46.2534184Z INFO: Load active rules (done) | time=640ms
2020-06-11T21:37:46.2988612Z INFO: Indexing files…
2020-06-11T21:37:46.2989180Z INFO: Project configuration:
2020-06-11T21:37:46.2992464Z INFO: Excluded sources: /node_modules/, **/.spec.ts, **/.scss, **/.spec.ts
2020-06-11T21:37:46.2992669Z INFO: Included tests: **/
.spec.ts
2020-06-11T21:37:46.6553640Z INFO: Load project repositories
2020-06-11T21:37:46.7197488Z INFO: Load project repositories (done) | time=78ms
2020-06-11T21:37:46.9783870Z INFO: 176 files indexed
2020-06-11T21:37:46.9784427Z INFO: 224 files ignored because of inclusion/exclusion patterns
2020-06-11T21:37:46.9784609Z INFO: 0 files ignored because of scm ignore settings
2020-06-11T21:37:46.9789441Z INFO: Quality profile for css: Oxy way
2020-06-11T21:37:46.9793109Z INFO: Quality profile for ts: Oxy Way
2020-06-11T21:37:46.9793346Z INFO: Quality profile for web: Sonar way
2020-06-11T21:37:46.9793495Z INFO: ------------- Run sensors on module OLT UI
2020-06-11T21:37:47.0579841Z INFO: Load metrics repository
2020-06-11T21:37:47.0747507Z INFO: Load metrics repository (done) | time=16ms
2020-06-11T21:37:48.2199408Z INFO: Sensor SonarCSS Metrics [cssfamily]
2020-06-11T21:37:48.2831295Z INFO: Sensor SonarCSS Metrics [cssfamily] (done) | time=63ms
2020-06-11T21:37:48.2832120Z INFO: Sensor JaCoCo XML Report Importer [jacoco]
2020-06-11T21:37:48.2867024Z INFO: ‘sonar.coverage.jacoco.xmlReportPaths’ is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
2020-06-11T21:37:48.2878858Z INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
2020-06-11T21:37:48.2879114Z INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
2020-06-11T21:37:48.2879247Z INFO: Sensor SonarJS Coverage [javascript]
2020-06-11T21:37:48.2881220Z WARN: The use of sonar.typescript.lcov.reportPaths for coverage import is deprecated, use sonar.javascript.lcov.reportPaths instead.
2020-06-11T21:37:48.2890696Z WARN: No coverage information will be saved because LCOV file cannot be found.
2020-06-11T21:37:48.2895112Z WARN: Provided LCOV file path: MyProject/coverage/lcov.info. Seek file with path: D:\TFSBuild\azure_agent.2_work\136\s\MyProject\coverage\lcov.info
2020-06-11T21:37:48.2895280Z WARN: No coverage information will be saved because all LCOV files cannot be found.
2020-06-11T21:37:48.2895379Z INFO: Sensor SonarJS Coverage [javascript] (done) | time=0ms
2020-06-11T21:37:48.2895457Z INFO: Sensor TypeScript analysis [javascript]
2020-06-11T21:38:06.2847235Z INFO: Using TypeScript at: ‘D:\TFSBuild\azure_agent.2_work\136\s\MyProject\node_modules@compodoc\ngd-core\node_modules’
2020-06-11T21:38:10.7954991Z INFO: Found 1 tsconfig.json file(s): [D:\TFSBuild\azure_agent.2_work\136\s\MyProject\tsconfig.json]
2020-06-11T21:38:10.8857994Z INFO: 90 source files to be analyzed
2020-06-11T21:38:10.8858968Z INFO: Analyzing 90 files using tsconfig: D:\TFSBuild\azure_agent.2_work\136\s\MyProject\tsconfig.json
2020-06-11T21:38:10.9137720Z ##[error]ERROR: You are using version of TypeScript 2.7.2 which is not supported; supported versions >=3.2.1
ERROR: If it’s not possible to upgrade version of TypeScript used by the project, consider installing supported TypeScript version just for the time of analysis
2020-06-11T21:38:10.9145296Z ERROR: You are using version of TypeScript 2.7.2 which is not supported; supported versions >=3.2.1
2020-06-11T21:38:10.9145758Z
2020-06-11T21:38:10.9147351Z ##[error]ERROR: Failure during analysis, Node.js command to start eslint-bridge was: {NODE_PATH=C:\ProgramData\npm\node_modules;D:\TFSBuild\azure_agent.2_work\136\s\MyProject\node_modules@compodoc\ngd-core\node_modules} node D:\TFSBuild\azure_agent.2_work\136\s.scannerwork.sonartmp\eslint-bridge-bundle\package\bin\server 64631
java.lang.IllegalStateException: Unsupported TypeScript version
at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.processParsingError(AbstractEslintSensor.java:149)
at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.processResponse(AbstractEslintSensor.java:188)
at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyze(TypeScriptSensor.java:154)
at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyzeFilesWithTsConfig(TypeScriptSensor.java:141)
at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyzeFiles(TypeScriptSensor.java:121)
at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.execute(AbstractEslintSensor.java:107)
at org.sonar.plugins.javascript.eslint.TypeScriptSensor.execute(TypeScriptSensor.java:53)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:386)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:382)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:351)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
2020-06-11T21:38:10.9149200Z ERROR: Failure during analysis, Node.js command to start eslint-bridge was: {NODE_PATH=C:\ProgramData\npm\node_modules;D:\TFSBuild\azure_agent.2_work\136\s\MyProject\node_modules@compodoc\ngd-core\node_modules} node D:\TFSBuild\azure_agent.2_work\136\s.scannerwork.sonartmp\eslint-bridge-bundle\package\bin\server 64631
2020-06-11T21:38:10.9149321Z java.lang.IllegalStateException: Unsupported TypeScript version
2020-06-11T21:38:10.9149411Z at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.processParsingError(AbstractEslintSensor.java:149)
2020-06-11T21:38:10.9149488Z at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.processResponse(AbstractEslintSensor.java:188)
2020-06-11T21:38:10.9149563Z at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyze(TypeScriptSensor.java:154)
2020-06-11T21:38:10.9149650Z at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyzeFilesWithTsConfig(TypeScriptSensor.java:141)
2020-06-11T21:38:10.9149780Z at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyzeFiles(TypeScriptSensor.java:121)
2020-06-11T21:38:10.9149870Z at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.execute(AbstractEslintSensor.java:107)
2020-06-11T21:38:10.9149943Z at org.sonar.plugins.javascript.eslint.TypeScriptSensor.execute(TypeScriptSensor.java:53)
2020-06-11T21:38:10.9150078Z at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
2020-06-11T21:38:10.9150150Z at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
2020-06-11T21:38:10.9150238Z at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
2020-06-11T21:38:10.9150313Z at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
2020-06-11T21:38:10.9150402Z at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
2020-06-11T21:38:10.9150475Z at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
2020-06-11T21:38:10.9150555Z at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
2020-06-11T21:38:10.9150640Z at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
2020-06-11T21:38:10.9150719Z at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:386)
2020-06-11T21:38:10.9150803Z at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:382)
2020-06-11T21:38:10.9150876Z at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:351)
2020-06-11T21:38:10.9150959Z at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
2020-06-11T21:38:10.9151030Z at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
2020-06-11T21:38:10.9151109Z at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
2020-06-11T21:38:10.9151187Z at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
2020-06-11T21:38:10.9151269Z at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
2020-06-11T21:38:10.9151337Z at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
2020-06-11T21:38:10.9151434Z at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
2020-06-11T21:38:10.9151507Z at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
2020-06-11T21:38:10.9151588Z at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2020-06-11T21:38:10.9151660Z at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2020-06-11T21:38:10.9151732Z at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2020-06-11T21:38:10.9151807Z at java.lang.reflect.Method.invoke(Method.java:498)
2020-06-11T21:38:10.9151879Z at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
2020-06-11T21:38:10.9151967Z at com.sun.proxy.$Proxy0.execute(Unknown Source)
2020-06-11T21:38:10.9152035Z at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
2020-06-11T21:38:10.9152115Z at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
2020-06-11T21:38:10.9152188Z at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
2020-06-11T21:38:10.9152253Z at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
2020-06-11T21:38:10.9152330Z at org.sonarsource.scanner.cli.Main.main(Main.java:61)
2020-06-11T21:38:10.9152373Z
2020-06-11T21:38:10.9152450Z INFO: Sensor TypeScript analysis [javascript] (done) | time=22625ms
2020-06-11T21:38:10.9152514Z INFO: Sensor JavaXmlSensor [java]
2020-06-11T21:38:10.9152577Z INFO: Sensor JavaXmlSensor [java] (done) | time=0ms
2020-06-11T21:38:10.9152672Z INFO: Sensor HTML [web]
2020-06-11T21:38:11.1535458Z INFO: Sensor HTML [web] (done) | time=234ms
2020-06-11T21:38:11.1535985Z INFO: Sensor SonarTS [typescript]
2020-06-11T21:38:11.1536102Z INFO: Since SonarTS v2.0, TypeScript analysis is performed by SonarJS analyzer v6.0 or later. No TypeScript analysis is performed by SonarTS.
2020-06-11T21:38:11.1536178Z INFO: Sensor SonarTS [typescript] (done) | time=0ms
2020-06-11T21:38:11.1568506Z INFO: ------------- Run sensors on project
2020-06-11T21:38:11.1607705Z INFO: Sensor Zero Coverage Sensor
2020-06-11T21:38:11.1628662Z INFO: Sensor Zero Coverage Sensor (done) | time=0ms
2020-06-11T21:38:11.3386483Z INFO: CPD Executor 10 files had no CPD blocks
2020-06-11T21:38:11.3386732Z INFO: CPD Executor Calculating CPD for 10 files
2020-06-11T21:38:11.3591376Z INFO: CPD Executor CPD calculation finished (done) | time=31ms
2020-06-11T21:38:11.5843978Z INFO: Analysis report generated in 203ms, dir size=469 KB
2020-06-11T21:38:11.7811462Z INFO: Analysis report compressed in 203ms, zip size=187 KB
2020-06-11T21:38:11.8615478Z INFO: Analysis report uploaded in 78ms
2020-06-11T21:38:11.8654689Z INFO: ANALYSIS SUCCESSFUL, you can browse http://sonarserver:9000/dashboard?id=sysdev-OLT-ui
2020-06-11T21:38:11.8654979Z INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
2020-06-11T21:38:11.8655127Z INFO: More about the report processing at http://sonarserver:9000/api/ce/task?id=AXKlUakEG2qwhaD7P5KZ
2020-06-11T21:38:13.1323442Z INFO: Analysis total time: 28.201 s
2020-06-11T21:38:13.1350736Z INFO: ------------------------------------------------------------------------
2020-06-11T21:38:13.1350938Z INFO: EXECUTION SUCCESS
2020-06-11T21:38:13.1351466Z INFO: ------------------------------------------------------------------------
2020-06-11T21:38:13.1352035Z INFO: Total time: 29.138s
2020-06-11T21:38:13.2321295Z INFO: Final Memory: 20M/584M
2020-06-11T21:38:13.2321528Z INFO: ------------------------------------------------------------------------
2020-06-11T21:38:13.3335050Z ##[section]Finishing: Run Code Analysis

It seems like we are using transitive typescript dependency.

Ticket is there already Prefer direct project TypeScript dependency to a transitive one · Issue #1928 · SonarSource/SonarJS · GitHub, we will fix it for the next release.

Thank you, Elena!

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