How to fix: VSCode: Cannot launch program ‘…/app/ts’ because corresponding JavaScript cannot be found.

 

I compiled a very simple node.js express application with tsc (TypeScript) on the command line and wanted to debug it with VSCode, but when I pressed F5 I got the error: Cannot launch program ‘…/app/ts’ because corresponding JavaScript cannot be found.

 

I expected the paths in the launch.json to be wrong, but that was not the case.

The problem was that I did not generate *.js.map files.

After I changed the tsconfig.json file, to generate *.js.map files, I could debug the application.

 

tsconfig.json

{

“compileOnSave”: false,

“compilerOptions”: {

“target”: “ES2015”,

“module”: “commonjs”,

“sourceMap”: true,

“strict”: true

}

}

 

 

Preventing multiple WDS disconnects in Chrome on Windows 10, by trusting the self-signed https certificate, generated by Angular CLI ng serve –ssl true

 

If you use ng serve with the parameter –ssl true, to serve your Angular application.

It will generate a self-signed https certificate, so you can run the Angular application on localhost using HTTPS.

By default this certificate is NOT trusted by your browser, so you will get a red cross, left to the url.

Because this certificate is not trusted, you might get multiple WDS disconnect errors in the chrome developer tools console.

Sometimes ending in a never-ending loop.

If you want to trust the self-signed https certificate:

  • click on the red cross (a popup opens)
  • choose Certificate
  • Click on Details
  • Click on Copy to file

 

Press next

 

Choose DER encoded binary X.509 (.CER)

Enter C:\Temp\localhost.cer

 

Press Finish

 

Go to C:\Temp with the explorer and double click on the localhost.cer file.

 

 

Press Install Certificate…

 

Choose “Local Machine” if you want the certificate be trusted for all user of this computer.

 

 

To remove the certificate on Windows 10

  • Open Start, type certmgr.msc
  • Click on “Trusted Root Certification Authorities” > Certificates
  • Right click on localhost and choose Delete

 

How to exit long output from a git command (like git branch -a, git log, git diff)

 

When you have a lot of git branches, the output of git branch -a will be shown in the “less” program.

The first “x” branches are shown and at the bottom the pager cursor will be shown:

 

Now when you press “q”, the less program will quit and you will be returned to the command prompt.

Pressing “h” will show help.

Pressing “arrow down” will scroll one row.

Pressing “page down” will scroll a screen.

When you reach the end of the output, the text “END” will be shown:

 

Press “q” to return to the command prompt

 

See: https://stackoverflow.com/questions/9483757/how-to-exit-git-log-or-git-diff

Fixing – events.js:183 throw er; // Unhandled ‘error’ event, when npm installing PhantomJS

 

When running npm install inside my project folder, I got the error events.js:183 throw er; // Unhandled ‘error’ event

This was caused by an other terminal running my application.

After killing al terminals and browsers this error was fixed.

 

Error

PS C:\Dev\MyProject1> npm install

 

> entry@0.0.0 postinstall C:\Dev\MyProject1

> webdriver-manager update & node node_modules/phantomjs-prebuilt/install.js

 

events.js:183

throw er; // Unhandled ‘error’ event

^

 

Error: read ECONNRESET

at TLSWrap.onread (net.js:622:25)

Found PhantomJS at C:\Dev\MyProject1\node_modules\phantomjs-prebuilt\lib\phantom\bin\phantomjs.exe …verifying

PhantomJS is previously installed at C:\Dev\\MyProject1\node_modules\phantomjs-prebuilt\lib\phantom\bin\phantomjs.exe