启用SourceMap的VSCODE DEBUG DEBUG打字错误错误
我有一个打字稿应用。 SRC在SRC目录中。如果我运行构建并启动应用程序,则可以正常工作。现在我想调试它。 https://code.vis.visalstudio.com/docs/docs/docs/docs/typescript-cript-tuterororage _debugging
打字稿是模块格式。将在磁盘目录中生成的输出没有模块,因为tsconfig.json文件具有选项集。
因此,问题是,如果我制作任务的配置。这是一个节点应用。
启动.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/src/index.ts",
"preLaunchTask": "tsc: build - tsconfig.json",
"console": "integratedTerminal",
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": ["$tsc"]
}
]
}
tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"experimentalDecorators": true ,
"emitDecoratorMetadata": true ,
"module": "commonjs",
"sourceMap": true ,
"outDir": "./dist" ,
"sourceRoot": "./src/",
"esModuleInterop": true ,
"forceConsistentCasingInFileNames": true ,
"strict": true ,
"skipLibCheck": true
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
}
错误告诉我:(单击我单击VSCODE F5中的启动调试按钮后触发)
PS C:\Users\ruper\Documents\Code\javaScript\microtrading> ${env:NODE_OPTIONS}='--require c:/Users/ruper/.vscode/extensions/ms-vscode.js-debug-nightly-2022.5.2017/src/bootloader.bundle.js --inspect-publish-uid=http'; ${env:VSCODE_INSPECTOR_OPTIONS}='{"inspectorIpc":"\\\\.\\pipe\\node-cdp.3248-1.sock","deferredMode":false,"waitForDebugger":"","execPath":"C:\\Program Files\\nodejs\\node.exe","onlyEntrypoint":false,"autoAttachMode":"always","fileCallback":"C:\\Users\\ruper\\AppData\\Local\\Temp\\node-debug-callback-5c4d148c5f27f944"}'; & 'C:\Program Files\nodejs\node.exe' '.\src\index.ts'
Debugger attached.
(node:22324) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
Waiting for the debugger to disconnect...
C:\Users\ruper\Documents\Code\javaScript\microtrading\src\index.ts:1
import dotenv from 'dotenv'
^^^^^^
SyntaxError: Cannot use import statement outside a module
I have a typescript app. The src is in the src directory. If i run the build, and start the app, it works. Now I want to debug it. https://code.visualstudio.com/docs/typescript/typescript-tutorial#_debugging
The typescript is in module format. The output which will be generated in the disk directory has no module, because the tsconfig.json file has the option set.
So, the problem is, if I make the config of the tasks.json, launch.json and run debug, it won't work. It's a node app.
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/src/index.ts",
"preLaunchTask": "tsc: build - tsconfig.json",
"console": "integratedTerminal",
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": ["$tsc"]
}
]
}
tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"experimentalDecorators": true ,
"emitDecoratorMetadata": true ,
"module": "commonjs",
"sourceMap": true ,
"outDir": "./dist" ,
"sourceRoot": "./src/",
"esModuleInterop": true ,
"forceConsistentCasingInFileNames": true ,
"strict": true ,
"skipLibCheck": true
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
}
The Error tells me: (Trigger after I click Start Debugging Button in VSCode F5)
PS C:\Users\ruper\Documents\Code\javaScript\microtrading> ${env:NODE_OPTIONS}='--require c:/Users/ruper/.vscode/extensions/ms-vscode.js-debug-nightly-2022.5.2017/src/bootloader.bundle.js --inspect-publish-uid=http'; ${env:VSCODE_INSPECTOR_OPTIONS}='{"inspectorIpc":"\\\\.\\pipe\\node-cdp.3248-1.sock","deferredMode":false,"waitForDebugger":"","execPath":"C:\\Program Files\\nodejs\\node.exe","onlyEntrypoint":false,"autoAttachMode":"always","fileCallback":"C:\\Users\\ruper\\AppData\\Local\\Temp\\node-debug-callback-5c4d148c5f27f944"}'; & 'C:\Program Files\nodejs\node.exe' '.\src\index.ts'
Debugger attached.
(node:22324) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
Waiting for the debugger to disconnect...
C:\Users\ruper\Documents\Code\javaScript\microtrading\src\index.ts:1
import dotenv from 'dotenv'
^^^^^^
SyntaxError: Cannot use import statement outside a module
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论