Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Build fails due to a Typescript Error
glosrob
#1 Posted : Saturday, January 23, 2021 11:08:01 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/23/2021(UTC)
Posts: 3
Location: United Kingdom

Thanks: 1 times
My main Web project fails to build due to a Typescript/import error (I assume because the reference is looking for something in node_modules).

Build\scripts\data\UserApi.ts (1, 38): BuildCannot find module '../../../node_modules/axios/index'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?

However, the project runs fine on F5 and indeed the Typescript works fine (Axios in this case makes HTTP requests as expected).

Any ideas how I can get NCrunch to ignore TS/node dependencies entirely? I only want it running my C#/serverside tests.

glosrob
#2 Posted : Saturday, January 23, 2021 11:25:14 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/23/2021(UTC)
Posts: 3
Location: United Kingdom

Thanks: 1 times
OK by right clicking the project that is failing to build in the nCrunch Tests window, go to Advanced and then from there you can browse to the folder where nCrunch builds the project. I watched a couple of times and realised that I don't have anything telling nCrunch to npm install (or similar).

Is there a recommended way to set this up?

I am using VS 2019 if it matters.
Remco
#3 Posted : Sunday, January 24, 2021 12:42:27 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for sharing this issue.

Broadly, you have two options here. You can either disable typescript compilation by adding a condition to your project file, or you can make sure it has the dependencies necessary to run without errors inside the NCrunch workspace.

The root issue is that your typescript build step requires certain files to be present on paths relative to the solution being compiled. These files haven't been auto detected by NCrunch, so they don't get copied into its workspace when it builds your project. You'll need to specify the files using the additional files to include setting so then NCrunch is aware of them and can copy them over. Probably it's best to just include the entire node_modules directory. Hopefully that will resolve the issue and you'll be able to have typescript compilation results showing up in the NCrunch Tests Window.
1 user thanked Remco for this useful post.
glosrob on 1/24/2021(UTC)
glosrob
#4 Posted : Sunday, January 24, 2021 12:49:40 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/23/2021(UTC)
Posts: 3
Location: United Kingdom

Thanks: 1 times
Makes sense, thanks for the quick reply.
rlawley
#5 Posted : Thursday, December 30, 2021 1:17:19 PM(UTC)
Rank: Member

Groups: Registered
Joined: 4/7/2014(UTC)
Posts: 11
Location: United Kingdom

Thanks: 2 times
Was thanked: 4 time(s) in 4 post(s)
Came across this post while looking to disable typescript build from ncrunch. With the link on conditions from here plus a page from somewhere else, here's the simple way:

Code:
<PropertyGroup>
  <TypeScriptCompileBlocked Condition="'$(NCrunch)' == '1'">true</TypeScriptCompileBlocked>
</PropertyGroup>
1 user thanked rlawley for this useful post.
Remco on 12/31/2021(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.047 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download