Unable to resolve Typescript error when building 2 projects


We’ve got a pipeline in which we build 2 projects. One project contains the .net code and the other project contains all our typescripts.

When we initially tried to build the typescript project, there was a sonar error: ERROR: Failed to find ‘typescript’ module.
We solved this by implementing the solution as described at:

But as soon as we enable the second project build in this pipeline (the c# one), the error occurs again.

##[error]13:50:35.217 ERROR: Cannot find module ‘typescript’
13:50:35.217 ERROR: TypeScript dependency was not found and it is required for analysis.
13:50:35.217 ERROR: Install TypeScript in the project directory or use NODE_PATH env. variable to set TypeScript location, if it’s located outside of project directory.
13:50:35.217 ERROR: Missing TypeScript dependency
org.sonar.plugins.javascript.eslint.MissingTypeScriptException: Missing TypeScript dependency

Can you help us to resolve this issue with the sonar scan?

I had a similar issue and I solved it using the code from this post: Typescript analysis breaks based on analysis order
Which is pretty similar to what you do. The only difference I could see is that you set NODE_PATH in a different way. This might be the issue since before I used the way of setting it described in my post, the variable didn’t persist past the powershell script. Hopefully this can help you.

1 Like

Thank you @timster01! This solved our issue :slight_smile:

1 Like