Kay*_*yes 10 node.js visual-studio-code
我有一个节点项目作为我的主项目中的子文件夹。我正在尝试为 VS Code 创建启动配置,以便在我打开父文件夹时它开始调试 index.ts 文件。我的文件夹结构如下:
所以我的节点项目位于名为 NodeBackend 的子文件夹中。我想按 VS Code 上的 F5 或绿色按钮并开始调试我的打字稿文件。
当我从父文件夹中执行此操作时,出现错误:
Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
Run Code Online (Sandbox Code Playgroud)
但是,当我在 VS 代码中加载“NodeBackend”项目并按 F5 或绿色按钮时,我可以毫无问题地调试它。
我的启动.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}\\NodeBackend",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\NodeBackend\\src\\index.ts",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
这是我的源代码: https: //github.com/Kayes-Islam/SimpleProject
小智 1
这是我的类似项目结构的 launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Express",
"skipFiles": [
"<node_internals>/**"
],
"cwd": "${workspaceFolder}\\backend",
"program": "${workspaceFolder}\\backend\\src\\app.ts",
"runtimeArgs": [
"-r",
"ts-node/register",
"-r",
"tsconfig-paths/register"
],
"outFiles": [
"${workspaceFolder}/**/*.js"
],
}
]
}
Run Code Online (Sandbox Code Playgroud)
尽管控制台显示以下错误,但上述配置仍然有效:
C:\Program Files\nodejs\node.exe -r ts-node/register -r tsconfig-paths/register .\src\app.ts
Could not read source map for file:///C:/Users/path/to/project/backend/node_modules/typescript/lib/typescript.js: ENOENT: no such file or directory, open 'c:\Users\path\to\project\backend\node_modules\typescript\lib\typescript.js.map'
(node:23068) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Run Code Online (Sandbox Code Playgroud)
希望能有所帮助。干杯,
归档时间: |
|
查看次数: |
3713 次 |
最近记录: |