Skip to content

Instantly share code, notes, and snippets.

@mid0111
Last active October 3, 2019 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mid0111/90eb73f730238ef54c748d6c02b50b22 to your computer and use it in GitHub Desktop.
Save mid0111/90eb73f730238ef54c748d6c02b50b22 to your computer and use it in GitHub Desktop.
Nuxt express debug with VS Code

Nuxt js を express で SSR している構成の場合、サーバサイドのデバッグが必要になるけど、ネット上の情報は古いのか、ルート以外の URL にアクセスすると 404 Not Found となってしまった。

そこで、node から nuxt を実行するのではなく、通常の dev の定義と同じく server/index.js を起動してそこにアタッチするやり方にしてみたところ動いた。

package.json

  "scripts": {
    "debug": "cross-env NODE_ENV=development nodemon --inspect-brk=9229 server/index.js --watch server",
    "dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server",
     :
  },

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "server: nuxt",
      "runtimeExecutable": "npm",
      "runtimeArgs": [
        "run-script",
        "debug"
      ],
      "console": "integratedTerminal",
      "sourceMaps": true,
      "port": 9229
    },
  ]
}

クライアント側のデバッグは chrome 上になるけど、サーバサイドもクライアントこれでデバッグ可能になったはず。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment