-
Notifications
You must be signed in to change notification settings - Fork 27.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debugger setup tuning for using VS Code with the mern.io starter kit #22378
Comments
Issue 3 from above is the result of a changed API. See #22409 for details. It is fixed in the Insiders by now. |
Perhaps we can make a variant of the mern-starter that includes the launch.json and updated package.json, then make a PR on the mern-cli. See "make your mern" at http://mern.io/ . |
added "console": "integratedTerminal" And was able to launch the app under the debugger. However, I could only ever get it to hit a breakpoint one time. |
FYI When using |
Closing the issue as:
|
@michelkaporin thanks for the update! I'm reopening this because I don't know what to do as a user still :) Imagine I'm new to VS Code and I'm learning MERN. I read our docs and press F5 and nothing seems to work. What do I do? Our model is to configure the launch.json in such a way that F5 just works. The suggestion above to launch through the integrated terminal sounds like a workaround? My question then is, what is the proper setup in VS Code to get debugging to just work here, and how can we make that easier? |
@chrisdias The proper setup is described in the initial post here by @egamma, which works good and verified with respect to raised bullet points for this issue. Regards the process simplifying I would propose to create a mern-starter kit for VS Code developers. As you pointed out we can do it with the help of "make your mern" at http://mern.io, where we can add the debug configuration listed above that works fine and enables a debugging for a user. Doing auto-detection of MERN stack on F5 seems also a nice idea, although I don't know how this works now and how we can integrate it, maybe @weinand can give a light on it. |
Once debugging is stopped, you see the below in the terminal:
nodemon should exit when user exits the debug session |
@chrisdias some comments: We have verified that the proposed launch config (see below) works as expected: pressing F5 runs MERN's own "npm run start" but with debugging enabled. It takes some time (30 secs) until everything has been build and webpacked but in the end the user sees a "MERN is running on port: 8000! Build something amazing!" The launch config has to use the integrated terminal because "npm run start" uses "nodemon" which is an interactive tool that reads from stdin (nodemon outputs: "to restart at any time, enter This is the definitive launch config (which relies on a new start:debug script in the package.json): {
"name": "Launch via NPM script",
"type": "node",
"request": "launch",
"protocol": "inspector",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
},
"runtimeArgs": [
"run-script",
"start:debug"
],
"timeout": 20000,
"restart": true,
"port": 5858,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
} We could try to detect MERN in the node extension and generate the launch config from above automatically, but I don't think that this approach is sustainable because we would have to track all changes in the underlying frameworks and adapt our launch config generation code frequently. A better approach is to let MERN maintain the launch config on their side. There are two remaining issues (which are independent from MERN and are covered by separate issues):
|
I've added experimental support for MERN launching: if MERN starter kit is detected a corresponding launch config is generated (if none exist). |
The automatically generated launch config assumes that "nodemon" is installed globally. |
Btw., I'm still asked for the environment before the generated launch is used, is that by design? |
I've added the |
A first cut of a "MERN Recipe" is available here: https://github.com/weinand/vscode-recipes/tree/master/MERN-Starter |
// CC @chrisdias
http://mern.io/ defines a starter kit for MERN. I was looking with @weinand into the best VS Code debugger setup.
The idea is to use an NPM launch configuration so that the vscode independent launching details can be defined inside the
package.son
and do not have to be defined inside the vscode specific launch configuration.I've added the following script to the starter kit's
package.json
in thescripts
section:With the following launch configuration we could launch and debug the target from VS Code.
The script sets
restart
to true since the starterkit is using nodemon and we want to reattach when nodemon restarts the target program.We've ran into the following glitches:
legacy
protocol and the--debug
option you get a timeout error.The text was updated successfully, but these errors were encountered: