- If you don’t use
webpack
Wait to package, but to adopttsc
Typescript has built-in packaging, so you need to be careful when using the debugger:
- If you use
import
Syntax, then need to installts-loader
Because thenode
The environment cannot be resolved directlyimport
Syntax to configure yourluncher.json
Vscode in the project - If you want to add
runtimeArgs
Configure vscode to tell vscode that you need to use the ts-loader in order to run in the node environmentts
File, encounteredimport
Will not return an error
{
// Use IntelliSense to learn about related attributes.
// Hover to view descriptions of existing properties.
/ / for more information, please visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0"."configurations": [{"type": "node"."request": "launch"."name": "Start program"."skipFiles": ["<node_internals>/**"]."runtimeArgs": [
"-r"."${workspaceFolder}/node_modules/ts-node/register"].// Get the TS-Node dependency for your current project
"program": "${workspaceFolder}/src/Index.ts"."outFiles": ["${workspaceFolder}/**/*.js"]."sourceMaps": true."protocol": "auto"}}]Copy the code