vscode 运行/调试 js/ts
js
js在安装node.js之后就可以直接在命令行中执行 node filename.js
ts
安装node.js
npm i typescript tsc-node -D根目录下新建
tsconfig.json,用于ts配置{ "compilerOptions": { "module": "commonjs", "target": "es6", "noImplicitAny": true, "outDir": "./dist", "sourceMap": true }, "include": [ "src/**/*", "**/*" ], }根目录下新建
.vscode文件夹,在文件加内新建launch.json{ // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "启动程序", "type": "node", "request": "launch", "runtimeArgs": [ "--nolazy", "-r", "ts-node/register" ], "sourceMaps": true, "cwd": "${workspaceRoot}", // "protocol": "inspector", "console": "integratedTerminal", // "internalConsoleOptions": "neverOpen", "skipFiles": [ "<node_internals>/**" ], "program": "${file}", "outFiles": [ "${workspaceFolder}/**/*.js" ] } ] }
调试步骤
- 点开需要调试的文件
- F5或点击菜单栏运行->启动调试

- 调试页面

