【发布时间】:2019-04-10 04:46:47
【问题描述】:
由于自动生成的 tsconfig 文件,我有一个 Angular 应用程序在保存时编译,但我不知道如何为 Node.js 服务器执行相同的操作。我是否需要修改launch.json 以某种方式引用另一个tsconfig.json?
这是我的 launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: start",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
},
{
"type": "node",
"request": "launch",
"name": "Launch JS",
"program": "${workspaceFolder}/src/app/nodeapi/nodeapi.js"
}
]
}
tsconfig.json
{
"compileOnSave": true,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}
我的项目结构:
|src
|-app
|--app.component.ts and other .TS files
|--nodeapi
|---nodeapi.js <---contains my server code
|tsconfig.json (shown above)
【问题讨论】:
标签: node.js visual-studio-code vscode-tasks