# Error: Cannot find module 'typescript'

**URL:** <https://community.sonarsource.com/t/error-cannot-find-module-typescript/4396>\
**Category:** SonarQube Server / Community Build\
**Tags:** typescript\
**Created:** [November 19, 2018, 2:47pm UTC](https://community.sonarsource.com/t/error-cannot-find-module-typescript/4396 "2018-11-19T14:47:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![RyanK](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@RyanK](https://community.sonarsource.com/u/RyanK)\
**Post date:** [November 19, 2018, 2:47pm UTC](https://community.sonarsource.com/t/error-cannot-find-module-typescript/4396/1 "2018-11-19T14:47:26Z")

</div>

Template for a good bug report, formatted with [Markdown](https://commonmark.org/help/):

- versions used (SonarQube, Scanner, Plugin, and any relevant extension)
- Community Edition Version 7.4 (build 18908)

I am using Team City as my CI.  
SQ is being hosted in a Win Server 2012 R2. 12 gb of Ram. I have more than 50gig free.  
When I have task manager RAM only 40% used

I have added several projects to SonarQube. Only a couple of project i encounter “Can not find typescript”  
According to documentation I my version is higher than the min. requirements.

if you take a look at another issue I posted, it list all the plug-in installed and version. [Out of memory: Java heap space](https://community.sonarsource.com/t/out-of-memory-java-heap-space/4357)

 ![Capture](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/5/5432f389e0ed0e418419e5a1eb9955829ec4d1ef.png)

---

<div class="post-metadata">

**Author:** ![Andrea\_Guarino](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/andrea_guarino/32/54797_2.png) [@Andrea\_Guarino](https://community.sonarsource.com/u/Andrea_Guarino)\
**Post date:** [November 20, 2018, 3:10pm UTC](https://community.sonarsource.com/t/error-cannot-find-module-typescript/4396/2 "2018-11-20T15:10:00Z")

</div>

Hi @RyanK,

SonarTS, i.e. our plugin used to analyze TypeScript files, needs to have “TypeScript” node module available either globally or locally on your project.

Given you already have node.js installed on your machine, you have two options:

- (_Recommended_) Running `npm install` before starting an analysis on each of your TS project to make TypeScript module available.
- Install TypeScript globally by running `npm install -g typescript`

Hope it clarifies.

Andrea

---

<div class="post-metadata">

**Author:** ![RyanK](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@RyanK](https://community.sonarsource.com/u/RyanK)\
**Post date:** [November 20, 2018, 10:19pm UTC](https://community.sonarsource.com/t/error-cannot-find-module-typescript/4396/3 "2018-11-20T22:19:16Z")

</div>

Thanks @Andrea_Guarino

I tried installing it globally, but it did not work. I had to have the type script install on per build configuration. Good thing I am using templates.

---

<div class="post-metadata">

**Author:** ![faizurrahmann](https://avatars.discourse-cdn.com/v4/letter/f/76d3ee/32.png) [@faizurrahmann](https://community.sonarsource.com/u/faizurrahmann)\
**Post date:** [July 24, 2019, 9:28am UTC](https://community.sonarsource.com/t/error-cannot-find-module-typescript/4396/4 "2019-07-24T09:28:12Z")

</div>

Hi RyanK,  
I am facing same error in my jenkins build while sonarscanner analyzing .ts file. I don’t know what exactly need to be done. I am familiar in sonar; but not in node.js. My very first question is: Is sonar using node.js to analyze .ts files? I tried installing it globally as \> npm install -g typescript; but didn’t work.

I tried setting up our NODE\_PATH by using “-Dsonar.typescript.node=” variable; but still facing the above error.

It would be great help if can guide me that how did you install type script on per build configuration? Thanks in Advance.

---

<div class="post-metadata">

**Author:** ![RyanK](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@RyanK](https://community.sonarsource.com/u/RyanK)\
**Post date:** [July 24, 2019, 3:27pm UTC](https://community.sonarsource.com/t/error-cannot-find-module-typescript/4396/5 "2019-07-24T15:27:53Z")

</div>

Hi Faizur

Its been a while. I do not full recall what we did to resolve the issue.  
With was either upgrade or downgrade the plug-in and/or fix the windows environment path.

Remember this is a Java base tool. Most errors that kick out does not provide a good idea what the issue is and/or there is a version issue from Operating system, Java runtimes, plug-ins, etc…

---

<div class="post-metadata">

**Author:** ![faizurrahmann](https://avatars.discourse-cdn.com/v4/letter/f/76d3ee/32.png) [@faizurrahmann](https://community.sonarsource.com/u/faizurrahmann)\
**Post date:** [July 25, 2019, 10:15am UTC](https://community.sonarsource.com/t/error-cannot-find-module-typescript/4396/6 "2019-07-25T10:15:33Z")

</div>

Thanks Ryan K for your response. plugin means sonar related plugin for typescript i.e., under $SONAR\_HOME/extensions/plugins?

---

<div class="post-metadata">

**Author:** ![RyanK](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@RyanK](https://community.sonarsource.com/u/RyanK)\
**Post date:** [July 26, 2019, 1:31pm UTC](https://community.sonarsource.com/t/error-cannot-find-module-typescript/4396/7 "2019-07-26T13:31:35Z")

</div>

I believe so…  
It could be the CI server, instead of the SQ server you need to make sure things are configured.

---

<div class="post-metadata">

**Author:** ![aeciobf](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/aeciobf/32/5442_2.png) [@aeciobf](https://community.sonarsource.com/u/aeciobf)\
**Post date:** [July 26, 2019, 5:44pm UTC](https://community.sonarsource.com/t/error-cannot-find-module-typescript/4396/8 "2019-07-26T17:44:32Z")

</div>

I am facing same error in my Azure Devops build .  
I tried the commands:

setx NODE\_PATH “$(Build.SourcesDirectory)\node\_modules” /M

cd $(Build.SourcesDirectory)

npm install -D typescript

But the error continues.

Any thoughts?

---

<div class="post-metadata">

**Author:** ![RyanK](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@RyanK](https://community.sonarsource.com/u/RyanK)\
**Post date:** [July 26, 2019, 6:47pm UTC](https://community.sonarsource.com/t/error-cannot-find-module-typescript/4396/9 "2019-07-26T18:47:00Z")

</div>

Sorry Aecio

I would suggest to make sure you have an update node and npm version.

> npm -v  
> node -v

I have been having a difficulties trying to get the MS Build to run. Not getting that much support over here. I am going to look at another tool before I make any purchase.

---

<div class="post-metadata">

**Author:** ![aeciobf](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/aeciobf/32/5442_2.png) [@aeciobf](https://community.sonarsource.com/u/aeciobf)\
**Post date:** [July 29, 2019, 1:32pm UTC](https://community.sonarsource.com/t/error-cannot-find-module-typescript/4396/10 "2019-07-29T13:32:24Z")

</div>

Thanks, Ryan K.

After several attempts, I got SonarQube to work properly on Azure Devops.  
Sonar worked only by installing the typescript module for each project. No need NODE\_PATH variable.  
For each project in the solution that has typescript code, run the following code in command line:  
cd $(Build.SourcesDirectory)\<PROJECT\_FOLDER\>  
npm install typescript.

I hope this helps.

---

<div class="post-metadata">

**Author:** ![RyanK](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@RyanK](https://community.sonarsource.com/u/RyanK)\
**Post date:** [July 29, 2019, 1:52pm UTC](https://community.sonarsource.com/t/error-cannot-find-module-typescript/4396/11 "2019-07-29T13:52:54Z")

</div>

Ah… Thanks @aeciobf …

That does ring a bell. I double checked my Team City template and my PowerShell function. I do have a step to install typescript during the CI process. The PS script I am using is

> npm install prerender-node --save;

Note: my PS script is a long switch statement with custom execution for CI build process… (ie… install type script, npm install commands, etc…). I did this so I only need to change 1 file and push that fill to all Team City Agents when things change instead of going to make changes to multiple process templates

Sorry @faizurrahmann - I forgot about this.

---

<div class="post-metadata">

**Author:** ![andrewandzz](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/andrewandzz/32/30006_2.png) [@andrewandzz](https://community.sonarsource.com/u/andrewandzz)\
**Post date:** [February 4, 2022, 5:47pm UTC](https://community.sonarsource.com/t/error-cannot-find-module-typescript/4396/12 "2022-02-04T17:47:51Z")

</div>

Thanks a lot, it worked for me.
