Afer changing TypeScriptOutDir breakpoints are never hit

I am using Visual Studio Professional 2013 Update 3 and I have created a Node console Application with the "hello world" log instruction. If I set a breakpoint in this instruction and then I run the debugger, it works perfectly fine. It hits the breakpoint and then I can debug as expected (just to make clear that my .map files are created and working correctly).

Now, I clean the project (remove the app.js and app.js.map generated files). I edit the .njsproj file and I add:

<TypeScriptOutDir>lib</TypeScriptOutDir>

I open the project again, update the startup file path by adding the additional "\lib" folder and I start debugging. It runs the code but it does not hit the breakpoint.

Why is not hitting the breakpoint? How the Visual Studio hit detection is working for typescript (node.js) projects since no .pdb files have been created when compiling? And how can I fix that so I can debug a compiled code that it's not located at the same folder as my source files?

Any suggestion, idea, feedback will be really appreciated. Thank you.

Note:

Checking the .js.map file generated in "\lib" I can see how the .ts file reference has an additional "..\" So the reference is alright. Anyway it seems like the problem is detecting the hit in the .js file rather than mapping the .js to .ts lines.

Update:

Steps to reproduce:

  1. Create a new project "Blank Node.js Console Application".
  2. Unload the project.
  3. Edit .njsproj xml and add this line: <TypeScriptOutDir>lib</TypeScriptOutDir>
  4. Reload project.
  5. Update startup file in the project by adding the "\lib" to the path.
  6. Open "app.ts" file.
  7. Set the breakpoint in the unique line of code "1. console.log('Hello world')"
  8. Start debugging.

Result: The app.js is generated in the "\lib" folder, VS runs the file with node, it prints the "Hello world" and finishes. No breakpoint hit.

Is it possible that setting breakpoints over a .ts file is always assuming that the .js file generated will be in the same folder as the .ts file?

I have tested setting the and to "lib" without any success in having the breackpoint in the .ts file and being hit.

Note:

If I set the breakpoint directly over the file generated in "\lib\app.js" it gets hit and the Visual Studio starts debugging but I still need it working setting the breakpoints in the .ts files.

Update2

Using the debug-working project (without the TypeScriptOutDir line in the .njsproj) I've manually changed the .js.map file where it says:

"sources":["app.ts"] to "sources":["app.ts"]

I have changed it to app2.ts:

"sources":["app.ts"] to "sources":["app2.ts"]

app2.ts is a non existing file. When we run the project now the breakpoint is not hit. I have also tried with an absolute path:

"sources":["W:/VS2013/projects/NodejsConsoleAppHit/app.ts"]

and it also works, but again if pointing to a non existing file it does not work:

"sources":["W:/VS2013/projects/NodejsConsoleAppHit/app2.ts"]

It looks like the app.js.map file is the responsible of mapping the breakpoints we set in the .ts file to the lines in the .js file.

Then, what is wrong with the app.js.map file generated in the lib folder? If we take a look to this file we can see a reference to the .ts file in the previous folder:

sources":["../app.ts"]

This should be alright since the path from "/lib/app.js" to "app.ts" is "../app.ts". But the result when we run the project is that the breakpoint is not hit.

Why? I have no idea and that is what I need to figure out.

I have also tried to manually modifying this references between relative and absolute without any success...

I have created two "Node.js console application" projects and set a breakpoint in the "hello world" log instruction.

The NodejsConsoleAppHit is the one WITHOUT the TypeScriptOutDir config. Is the one that generates the files in the project root folder and hits the breakpoint.

https://www.dropbox.com/s/mniuhm8mgnly3ff/NodejsConsoleAppHit.zip?dl=0

The NodejsConsoleAppNoHit is the one WITH the TypeScriptOutDir config. Is the one that generates the files in the lib folder and does not hit the breakpoint.

https://www.dropbox.com/s/dyadwxupltcg6gc/NodejsConsoleAppNoHit.zip?dl=0

According to this work item on the Node.js Tools for Visual Studio in CodePlex: https://nodejstools.codeplex.com/workitem/1428

The issue has been taken in account and fixed. I have tested it myself with "NTVS 1.0 RC VS 2013" and seems to be working fine.

You can get it choosing "NTVS 1.0 RC VS 2013" from the NTVS downloads page: https://nodejstools.codeplex.com/releases/view/149714

or directly going here: https://nodejstools.codeplex.com/downloads/get/946895

I have to say that we have been using node-inspector (https://github.com/node-inspector/node-inspector) for debugging in the meantime and it is a tool that works pretty fine and solved all our problems.

Personally still find the VS integration more convenient for ourselves. This is a matter of taste since, after this update of node.js tools, both seem to work fine.