Search code examples
debuggingvisual-studio-codestrapi

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?


Solution

  • 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.