nx icon indicating copy to clipboard operation
nx copied to clipboard

Debugging NextJS app broke with the update to 16. Maybe adding more docs for that ?

Open maxime4000 opened this issue 2 years ago • 0 comments

Current Behavior

So I just update our nx repo to the latest nx version (nwrl -> nx). But now our debugging config doesn't work anymore...

We had difficulties making the debug work for the server side part of our nextjs app in the first place, so it's a bummer that our config just don't work anymore and there is no proper solution for what I know.

Maybe adding docs for that and/or making the javascript debug terminal work would be nice!

Expected Behavior

So we would expect that this would do the trick but that's not working for us... https://www.youtube.com/watch?v=uQ7xpHyCBXI

By the way, why is that not working ? That would be nice if every nx app could be debug that way.

GitHub Repo

No response

Steps to Reproduce

This was our debug config for vscode :

{
  "version": "0.2.0",
  "resolveSourceMapLocations": ["${workspaceFolder}/**", "!**/node_modules/**"],
  "configurations": [
    {
      "name": "NextJS – Server",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "npx",
      "runtimeArgs": [
        "nx",
        "run",
        "next-app:serve:development",
        "-r",
        "ts-node/register",
        "-r",
        "tsconfig-paths/register"
      ],
      "outputCapture": "std",
      "internalConsoleOptions": "openOnSessionStart",
      "console": "internalConsole",
      "env": {
        "TS_NODE_IGNORE": "false",
        "TS_NODE_PROJECT": "${workspaceFolder}/packages/next-app/tsconfig.json"
      },
      "cwd": "${workspaceFolder}/packages/next-app/"
      //"cwd": "${workspaceFolder}"
    }
  ]
}

Problems appear because of the cwd settings. This settings will cause this error below. If we change the cwd settings to the commented one, now it's working but breakpoint doesn't work which defeat the purpose of having a debug config...

Nx Report

>  NX  Falling back to ts-node for local typescript execution. This may be a little slower.
  - To fix this, ensure @swc-node/register and @swc/core have been installed

 >  NX   Report complete - copy this into the issue template

   Node   : 18.16.0
   OS     : darwin arm64
   npm    : 9.5.1
   Hasher : Native
   
   nx                 : 16.3.2
   @nx/js             : 16.3.2
   @nx/jest           : 16.3.2
   @nx/linter         : 16.3.2
   @nx/workspace      : 16.3.2
   @nx/cypress        : 16.3.2
   @nx/devkit         : 16.3.2
   @nrwl/devkit       : 15.9.4
   @nx/eslint-plugin  : 16.3.2
   @nx/nest           : 16.3.2
   @nx/next           : 16.3.2
   @nx/node           : 16.3.2
   @nx/plugin         : 16.3.2
   @nx/react          : 16.3.2
   @nx/storybook      : 16.3.2
   @nrwl/tao          : 16.3.2
   @nx/vite           : 16.3.2
   @nx/web            : 16.3.2
   @nx/webpack        : 16.3.2
   typescript         : 5.1.3
   ---------------------------------------
   Community plugins:
   @nx-tools/nx-prisma : 5.0.0
   @nxlv/python        : 15.10.0
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   The following packages should match the installed version of nx
     - @nrwl/[email protected]
   
   To fix this, run `nx migrate [email protected]`

Failure Logs

> nx run next-app:serve:development -r ts-node/register -r tsconfig-paths/register

Debugger attached.
Waiting for the debugger to disconnect...
node:events:491
      throw er; // Unhandled 'error' event
      ^
Error: spawn /Users/maxime/.nvm/versions/node/v18.16.0/bin/node ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn /Users/maxime/.nvm/versions/node/v18.16.0/bin/node',
  path: '/Users/maxime/.nvm/versions/node/v18.16.0/bin/node',
  spawnargs: [
    '/Users/maxime/Repo/project/node_modules/next/dist/bin/next',
    'dev',
    '--port=1111',
    ''
  ]
}
Node.js v18.16.0

Operating System

  • [X] macOS
  • [ ] Linux
  • [ ] Windows
  • [ ] Other (Please specify)

Additional Information

Was working on nrwl/next 15.9.4, but now that we upgrade, it's no longer working with breakpoint reachable.

maxime4000 avatar Jun 13 '23 21:06 maxime4000