0、在命令行中,cd到项目下执行:
npm install
1、调试-》启动调试-》node.js, 会生成.vscode/launch.json文件
2、修改launch.json文件"program": "${workspaceRoot}/node_modules/lite-server/bin/lite-server"
3、任务:配置任务运行程序-》创建Typescript项目,生成tasks.json
4、Ctrl+Shift+B 运行,会报错,需要.vscode目录下增加settings.json文件:
// 将设置放入此文件中以覆盖默认值和用户设置。
{
"typescript.tsdk": "node_modules/typescript/lib",
// ts 项目, 隐藏 .js 和 .js.map 文件
"files.exclude": {
"node_modules": true,
"**/*.js": { "when": "$(basename).ts" },
"**/*.js.map": true
}
}
修改tasks.json文件:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "cmd",
"isShellCommand": true,
"showOutput": "always",
"args": ["/C npm start"]
}
6、Ctrl+Shift+B 运行Ok,弹窗自动访问http://localhost:3000/