Original address github.com/xiadd/blog/…
Most of the online tutorials are about front-end configuration of TS development and debugging. There are also a lot of mature practical tutorials. This article is mainly about NODEJS TS configuration, which is quite simple and does not involve any TS syntax and concepts. You can also use this article to configure the NODEJS development environment for ES6 (mainly the module part).
The use of ts – node
Babel-node is a similar tool that allows you to execute ts files without compiling them.
The installation
npm i -D typescript ts-nodeCopy the code
Create app.ts file:
//app.ts
console.log(1)Copy the code
Call the ts-Node app.ts command (in the case of a global installation), and if everything works, we should see the output we want.
All the way up to the top, there’s no point in going any further. Ts-node debugging is described below
debugging
Nodejs can be debugged using the following methods:
- Node-inspect is a third-party debugging tool that we won’t cover today
- Chrome developer tools, covered below
- Vs Code highlights today
- vs
- Webstorm is also quite handy
Vs Code debugging
Ts-node –inspect app.js: inspects node –inspect app.js: inspects node –inspect app.js: inspects node –inspect app.js
This means that you are ready to debug, but it seems that you can’t do things like break points, which is using vscode.
Open vscode debug panel to add debugging options and select attach to progess:
Then click Debug to pop up a pop-up window like the following:
Note the red box. There are several Node processes. Select the one with Inpect.
Chrome Developer Tools
This one is even easier. Open the developer tool on any web page and you can see the picture below
You can also debug by clicking on the Node icon:
But it doesn’t seem to be very stable, crashing a lot, and there are problems with Windows.
Finally, an example: github.com/xiadd/node-…
You can star if you are interested