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/