Thông thường để khởi động thông qua dòng lệnh, tôi có thể gõ:Chạy babel-nút trong mã visual studio
babel-node server.js
Khi tôi cố gắng thiết lập này để breakpoint và những gì không làm việc trong mã visual studio Tôi nhận :
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js --debug-brk=31893 --nolazy server.js
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 1: /Applications: is a directory
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 3: /Applications: is a directory
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 4: Dockerfile: command not found
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 5: syntax error near unexpected token `('
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 5: ` * when found, before invoking the "real" _babel-node(1) executable.'
tôi phỏng đoán nó đã làm với thực tế là thực thi đang được gọi là từ thư mục đó, chứ không phải là từ cùng thư mục với file server.js - nhưng tôi thực sự không biết.
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/server.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": "${workspaceRoot}/node_modules/babel-cli/lib/babel-node.js",
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
}
]
}
đáng chú ý rằng tôi cần phải thêm '.cmd' để con đường để có được nó làm việc trong Windows – cgatian
@cgatian bạn có thể xin giải thích như thế nào và nơi mà bạn đã thêm này của nó? – Jag
launch.json tôi tin. – cgatian