Debugging Javascript files in a multi-app React Django project using VS Code
I have a Django project that uses some React apps (via bundling from Webpack) besides other non-React javascript files. I would like to debug any javascript file inside Visual Studio Code (without using DevTools F12 from the browser).
There are some sites that explain how to debug javascript files using the Debugger for Chrome extension, but I could not find anywhere how to set this for a typical Django project structure.
I have followed the steps indicated in the answer of post Cannot debug in VSCode by attaching to Chrome, but instead of running serve -p 8080
, I run python manage.py runserver
from the console (by default it runs in port 8000).
Then, I have added the following launch configuration in launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "http://localhost:8000",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///./": "${webRoot}/",
"webpack:///src/": "${webRoot}/",
"webpack:///./~/": "${webRoot}/node_modules/",
"webpack:///": ""}
}
}
When I launch it, it goes to the correct url but it does not catch any breakpoint set in the javascript files. It says "unverified breakpoint" for any kind of javascript file:
${workspaceFolder}
points to the root of my Django structure. Hence, I would expect that all the Javascript files inside this root (even at different subfolders) should be catched by the extension. However, I am only able to debug a file (non-React) if I set to a webRoot
to a specific subfolder (e.g. "webRoot"="${workspaceFolder}/apps/app1/static"
). I can debug neither javascript files in other locations (like "app2" subdirectories) nor the React files, which are served by Webpack.
For the sake of completeness, I leave herein the working directory structure, where you can see the location of the javascript files:
apps/
app1/
migrations/
static/
app1/
css/
js/
react_app/
other javascript files
...
templates/
templatetags/
__init__.py
...
app2/
...
__init__.py
project_name/
__init__.py
celery.py
settings.py
urls.py
wsgi.py
manage.py
requirements.txt
.eslintrc.json
.babelrc
package.json
webpack.config.js
...
It is also worth noting that when running "Launch Chrome" configuration, I cannot debug the python files (they work when running "Python: Django" configuration).
To sum up, the main questions are:
- Is it possible to debug any kind of javascript file in different applications of a Django project?
- Could we debug both Python and Javascript files at the same time?
javascript python django debugging visual-studio-code
add a comment |
I have a Django project that uses some React apps (via bundling from Webpack) besides other non-React javascript files. I would like to debug any javascript file inside Visual Studio Code (without using DevTools F12 from the browser).
There are some sites that explain how to debug javascript files using the Debugger for Chrome extension, but I could not find anywhere how to set this for a typical Django project structure.
I have followed the steps indicated in the answer of post Cannot debug in VSCode by attaching to Chrome, but instead of running serve -p 8080
, I run python manage.py runserver
from the console (by default it runs in port 8000).
Then, I have added the following launch configuration in launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "http://localhost:8000",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///./": "${webRoot}/",
"webpack:///src/": "${webRoot}/",
"webpack:///./~/": "${webRoot}/node_modules/",
"webpack:///": ""}
}
}
When I launch it, it goes to the correct url but it does not catch any breakpoint set in the javascript files. It says "unverified breakpoint" for any kind of javascript file:
${workspaceFolder}
points to the root of my Django structure. Hence, I would expect that all the Javascript files inside this root (even at different subfolders) should be catched by the extension. However, I am only able to debug a file (non-React) if I set to a webRoot
to a specific subfolder (e.g. "webRoot"="${workspaceFolder}/apps/app1/static"
). I can debug neither javascript files in other locations (like "app2" subdirectories) nor the React files, which are served by Webpack.
For the sake of completeness, I leave herein the working directory structure, where you can see the location of the javascript files:
apps/
app1/
migrations/
static/
app1/
css/
js/
react_app/
other javascript files
...
templates/
templatetags/
__init__.py
...
app2/
...
__init__.py
project_name/
__init__.py
celery.py
settings.py
urls.py
wsgi.py
manage.py
requirements.txt
.eslintrc.json
.babelrc
package.json
webpack.config.js
...
It is also worth noting that when running "Launch Chrome" configuration, I cannot debug the python files (they work when running "Python: Django" configuration).
To sum up, the main questions are:
- Is it possible to debug any kind of javascript file in different applications of a Django project?
- Could we debug both Python and Javascript files at the same time?
javascript python django debugging visual-studio-code
add a comment |
I have a Django project that uses some React apps (via bundling from Webpack) besides other non-React javascript files. I would like to debug any javascript file inside Visual Studio Code (without using DevTools F12 from the browser).
There are some sites that explain how to debug javascript files using the Debugger for Chrome extension, but I could not find anywhere how to set this for a typical Django project structure.
I have followed the steps indicated in the answer of post Cannot debug in VSCode by attaching to Chrome, but instead of running serve -p 8080
, I run python manage.py runserver
from the console (by default it runs in port 8000).
Then, I have added the following launch configuration in launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "http://localhost:8000",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///./": "${webRoot}/",
"webpack:///src/": "${webRoot}/",
"webpack:///./~/": "${webRoot}/node_modules/",
"webpack:///": ""}
}
}
When I launch it, it goes to the correct url but it does not catch any breakpoint set in the javascript files. It says "unverified breakpoint" for any kind of javascript file:
${workspaceFolder}
points to the root of my Django structure. Hence, I would expect that all the Javascript files inside this root (even at different subfolders) should be catched by the extension. However, I am only able to debug a file (non-React) if I set to a webRoot
to a specific subfolder (e.g. "webRoot"="${workspaceFolder}/apps/app1/static"
). I can debug neither javascript files in other locations (like "app2" subdirectories) nor the React files, which are served by Webpack.
For the sake of completeness, I leave herein the working directory structure, where you can see the location of the javascript files:
apps/
app1/
migrations/
static/
app1/
css/
js/
react_app/
other javascript files
...
templates/
templatetags/
__init__.py
...
app2/
...
__init__.py
project_name/
__init__.py
celery.py
settings.py
urls.py
wsgi.py
manage.py
requirements.txt
.eslintrc.json
.babelrc
package.json
webpack.config.js
...
It is also worth noting that when running "Launch Chrome" configuration, I cannot debug the python files (they work when running "Python: Django" configuration).
To sum up, the main questions are:
- Is it possible to debug any kind of javascript file in different applications of a Django project?
- Could we debug both Python and Javascript files at the same time?
javascript python django debugging visual-studio-code
I have a Django project that uses some React apps (via bundling from Webpack) besides other non-React javascript files. I would like to debug any javascript file inside Visual Studio Code (without using DevTools F12 from the browser).
There are some sites that explain how to debug javascript files using the Debugger for Chrome extension, but I could not find anywhere how to set this for a typical Django project structure.
I have followed the steps indicated in the answer of post Cannot debug in VSCode by attaching to Chrome, but instead of running serve -p 8080
, I run python manage.py runserver
from the console (by default it runs in port 8000).
Then, I have added the following launch configuration in launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "http://localhost:8000",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///./": "${webRoot}/",
"webpack:///src/": "${webRoot}/",
"webpack:///./~/": "${webRoot}/node_modules/",
"webpack:///": ""}
}
}
When I launch it, it goes to the correct url but it does not catch any breakpoint set in the javascript files. It says "unverified breakpoint" for any kind of javascript file:
${workspaceFolder}
points to the root of my Django structure. Hence, I would expect that all the Javascript files inside this root (even at different subfolders) should be catched by the extension. However, I am only able to debug a file (non-React) if I set to a webRoot
to a specific subfolder (e.g. "webRoot"="${workspaceFolder}/apps/app1/static"
). I can debug neither javascript files in other locations (like "app2" subdirectories) nor the React files, which are served by Webpack.
For the sake of completeness, I leave herein the working directory structure, where you can see the location of the javascript files:
apps/
app1/
migrations/
static/
app1/
css/
js/
react_app/
other javascript files
...
templates/
templatetags/
__init__.py
...
app2/
...
__init__.py
project_name/
__init__.py
celery.py
settings.py
urls.py
wsgi.py
manage.py
requirements.txt
.eslintrc.json
.babelrc
package.json
webpack.config.js
...
It is also worth noting that when running "Launch Chrome" configuration, I cannot debug the python files (they work when running "Python: Django" configuration).
To sum up, the main questions are:
- Is it possible to debug any kind of javascript file in different applications of a Django project?
- Could we debug both Python and Javascript files at the same time?
javascript python django debugging visual-studio-code
javascript python django debugging visual-studio-code
edited Nov 27 '18 at 18:18
asked Nov 22 '18 at 16:03
David Duran
536824
536824
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434666%2fdebugging-javascript-files-in-a-multi-app-react-django-project-using-vs-code%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434666%2fdebugging-javascript-files-in-a-multi-app-react-django-project-using-vs-code%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown