This configuration is working fine for me:
Project distribution
|-- .vscode
|----- launch.json
|-- bin
|----- app.js
|----- app.js.map
|-- src
|----- app.ts
|-- node_modules
|-- [..]
|-- tsconfig.json
|-- [...]
The idea is compile the typescript under src
folder and place it under bin
folder.
tsconfig.json
It's important to active sourceMap
option.
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"module": "commonjs",
"target": "ES5",
"outDir": "bin",
"rootDir": "src",
"sourceMap": true
}
}
launch.json
==== EDIT ====
This is the configuration I'm currently using at Visual Studio Code v1:
{
"version": "0.2.0",
"configurations": [
{
"args": [],
"cwd": "${workspaceRoot}",
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"name": "DEBUG",
"outDir": "${workspaceRoot}/bin",
"preLaunchTask": "compile",
"program": "${workspaceRoot}/src/app.ts",
"request": "launch",
"runtimeArgs": [
"--nolazy"
],
"runtimeExecutable": null,
"sourceMaps": true,
"stopOnEntry": false,
"type": "node"
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858
}
]
}
Note the key preLaunchTask
is extremely helpful if you're using any task runner as gulp because the IDE is able to detect its tasks by name.
Running
- Compile your
ts
(typing in a terminal rm -r bin/ ; tsc
or executing your compiling task)
- In visual Code play
Launch type
(our configuration name)
- Enjoy!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…