Error when Analyzing Typescript File

1,498 views
Skip to first unread message

Rahul Goel

unread,
Dec 13, 2017, 1:17:01 AM12/13/17
to SonarQube
Hi All,

I am an error while analysis the Typescript file using SonarTS plugin, can somebody please help in analyzing the error and please let me know what i am doing wrong.

below is the stack trace of the error

2:09:01.754 INFO  - Sensor TypeScript Sensor [typescript]
22:09:04.266 ERROR - <path>\.sonar\sonarts-bundle\node_modules\tslint-sonarts\lib\runner\metrics.js:111
22:09:04.266 ERROR -     return walkAndCountIf(sourceFile, node => navigation_1.is(node, ...FUNCTION_KINDS));
22:09:04.266 ERROR -                                                                     ^^^
22:09:04.266 ERROR - 
22:09:04.266 ERROR - SyntaxError: Unexpected token ...
22:09:04.266 ERROR -     at exports.runInThisContext (vm.js:53:16)
22:09:04.266 ERROR -     at Module._compile (module.js:373:25)
22:09:04.266 ERROR -     at Object.Module._extensions..js (module.js:416:10)
22:09:04.266 ERROR -     at Module.load (module.js:343:32)
22:09:04.266 ERROR -     at Function.Module._load (module.js:300:12)
22:09:04.266 ERROR -     at Module.require (module.js:353:17)
22:09:04.266 ERROR -     at require (internal/module.js:12:17)
22:09:04.268 ERROR -     at Object.<anonymous> (<path>\.sonar\sonarts-bundle\node_modules\tslint-sonarts\lib\runner\processRequest.js:24:19)
22:09:04.268 ERROR -     at Module._compile (module.js:409:26)
22:09:04.268 ERROR -     at Object.Module._extensions..js (module.js:416:10)
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 22.024s
Final Memory: 22M/131M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
	at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
	at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
	at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
	at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
	at org.sonar.runner.api.Runner.execute(Runner.java:100)
	at org.sonar.runner.Main.executeTask(Main.java:70)
	at org.sonar.runner.Main.execute(Main.java:59)
	at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.IllegalStateException: Failed to run external process `node <path>\.sonar\sonarts-bundle\node_modules\tslint-sonarts\bin\tsrunner`. Run with -X for more information
	at org.sonar.plugin.typescript.ExternalTypescriptSensor.executeExternalRunner(ExternalTypescriptSensor.java:191)
	at org.sonar.plugin.typescript.ExternalTypescriptSensor.analyze(ExternalTypescriptSensor.java:118)
	at org.sonar.plugin.typescript.ExternalTypescriptSensor.execute(ExternalTypescriptSensor.java:103)
	at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
	at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
	at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
	at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:68)
	at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:88)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:180)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:288)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:283)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:261)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
	at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
	at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
	at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
	at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
	at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
	... 9 more
Caused by: java.io.IOException: The pipe has been ended
	at java.io.FileOutputStream.writeBytes(Native Method)
	at java.io.FileOutputStream.write(Unknown Source)
	at java.io.BufferedOutputStream.write(Unknown Source)
	at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)
	at sun.nio.cs.StreamEncoder.implWrite(Unknown Source)
	at sun.nio.cs.StreamEncoder.write(Unknown Source)
	at sun.nio.cs.StreamEncoder.write(Unknown Source)
	at java.io.OutputStreamWriter.write(Unknown Source)
	at java.io.Writer.write(Unknown Source)
	at org.sonar.plugin.typescript.ExternalTypescriptSensor.executeExternalRunner(ExternalTypescriptSensor.java:179)
	... 37 more
ERROR: 
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE

G. Ann Campbell

unread,
Dec 13, 2017, 5:33:14 AM12/13/17
to SonarQube
Hi,

I suspect you're missing step #4 here: If missing, install node.js on the machine where you run analysis.


Ann

Rahul Goel

unread,
Dec 14, 2017, 12:08:00 AM12/14/17
to SonarQube
Hi Ann,

Thanks for replying i have checked & node.js is installed on the analysis machine.

Regards
Rahul
Message has been deleted

Rahul Goel

unread,
Dec 14, 2017, 12:15:33 AM12/14/17
to SonarQube
On further analysis of the error log , i found the error is coming in this function and it is syntax error ("SyntaxError: Unexpected token")
return walkAndCountIf(sourceFile, node => is(node, ...FUNCTION_KINDS));

Stas Vilchik

unread,
Dec 14, 2017, 4:15:25 AM12/14/17
to SonarQube
Hi Rahul,

Could you tell me your nodejs version please (run "node -v") ?

Thanks!

Rahul Goel

unread,
Dec 14, 2017, 5:13:53 AM12/14/17
to Stas Vilchik, SonarQube
V4.5.0

--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/QW1Jlct7Qdo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/03173e1d-ea8c-45c0-b800-f0151a1cdc54%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Stas Vilchik

unread,
Dec 14, 2017, 5:17:13 AM12/14/17
to SonarQube
Unfortunately we support only node 6 or later.

FYI we plan to fail fast if the node is too old (see this issue).

Cheers
V4.5.0

To unsubscribe from this group and all its topics, send an email to sonarqube+...@googlegroups.com.

Rahul Goel

unread,
Dec 22, 2017, 3:48:08 AM12/22/17
to SonarQube
Thanks Stas,

I have upgraded to Node.js version to 8 and the error is gone, however now my analysis is giving the following error, can you please let me know what i am missing 

"Failed to find a source file matching path <path> in program created with <path>\tsconfig.json"


Regards 
Rahul

Rahul Goel

unread,
Dec 25, 2017, 11:19:19 PM12/25/17
to SonarQube
Team please help me here I am struck and need help.

Elena Vilchik

unread,
Dec 26, 2017, 4:09:18 AM12/26/17
to SonarQube
Hello,

This error means that the files are configured differently for SonarQube and for TypeScript: the file analyzed with SQ is not part of TS project. 
You can just ignore this error or try to configure SQ exclusions/inclusions more property.

Regards,
Elena

Rahul Goel

unread,
Dec 26, 2017, 5:35:21 AM12/26/17
to Elena Vilchik, SonarQube
Thanks Elena for reply but i have not done any configuration for SonarQube all i have done is sonar.language= ts for forcing only to scan ts file and now my analysis get complete but won't show any result all metrics are coming as zero. Let me know what i have missed.

To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/8d57b972-9cbf-47ec-8129-e26f481a51cd%40googlegroups.com.

Elena Vilchik

unread,
Dec 26, 2017, 5:46:38 AM12/26/17
to SonarQube
" i have not done any configuration for SonarQube" doesn't sound good to me:)
Have you configured sonar.sources?

In SQ "Code" tab do you see any files?

Rahul Goel

unread,
Jan 3, 2018, 3:28:09 AM1/3/18
to SonarQube
Yes i can see all the files in SQ code tab

also sonar.sources properties is set to "."

Please help i am struck and i see no way out

sorry for sounding desperate

Regards
Rahul

Elena Vilchik

unread,
Jan 3, 2018, 3:34:54 AM1/3/18
to SonarQube
I think it will be more effective if you will start a new thread (or even better, a new issue -> https://github.com/SonarSource/SonarTS/issues/new) describing all the current problems you have. 

Regards,
Elena
Reply all
Reply to author
Forward
0 new messages