Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging strapi in Visual Studio Code

I'm trying to debug my strapi project (3.0.0 beta 16.6) in VS Code. My launch.json:

{
  "type": "node",
  "request": "attach",
  "name": "Attach to strapi",
  "port": 9229
} 

My package.json:

"scripts": {
    "debug": "node --inspect=127.0.0.1:9229 ./node_modules/strapi/bin/strapi.js develop"
}

Debugger attaches to the process, but all my breakpoints become unverified (appear black, not red). What's wrong with my configs?

like image 513
alxnkt Avatar asked Sep 28 '19 10:09

alxnkt


People also ask

How do I run and debug a code in Visual Studio?

To bring up the Run and Debug view, select the Run and Debug icon in the Activity Bar on the side of VS Code. You can also use the keyboard shortcut Ctrl+Shift+D. The Run and Debug view displays all information related to running and debugging and has a top bar with debugging commands and configuration settings.

How do I run a JSON file in Visual Studio code?

In Visual Studio Code, use shortcut Ctrl + Shift + P to open the Command Palette and type Open launch. json . And it will open the launch. json file for you.

Where is launch json in Vscode?

The launch. json file is located in a . vscode folder in your workspace (project root folder).


1 Answers

this answer come from the following strapi/strapi issue:

I have come up with next solution: having next script in server.js file (my custom one):

const strapi = require('strapi');
strapi({ dir: process.cwd(), autoReload: true }).start();

I'm using nodemon by next command: nodemon --inspect=0.0.0.0:9228 server.js

Now I can attach to 9228 by debugger.

like image 151
Jim LAURIE Avatar answered Nov 09 '22 09:11

Jim LAURIE