Next.js: How do you debug Next.js internals?

Created on 13 Jun 2017  路  2Comments  路  Source: vercel/next.js

I want to get a deeper knowledge about Next.js internals, however, I have a problem with setting up an appropriate Node.js debug configurations on /examples/hello-world.

To do so I took the following steps:

  • cd examples/hello-world
  • npm install --save-dev babel-cli
  • changed "dev" script in package.json to the following one
"dev": "babel-node --debug --presets es2015 ../../bin/next",
  • added require('babel-register') to /bin/next-dev, but still it throws the following error:
C:\Code\temporary\next.js\bin\next-dev:3
import { resolve, join } from 'path'
^^^^^^
SyntaxError: Unexpected token import

Do you know what might be the reason?
How do you debug Next.js internals when running an exemplary project?

I wrote on Slack regarding this, but no response. In advance, thanks a lot for help. It is really important for me to debug properly in order to help you resolving any bugs, in case of free time :)

Most helpful comment

I am considering using Next.js in production, so I'd like to be able to debug internals easily without using console.log. Of course, debugging client and server side should be done separately.
The whole project is run in Node.js, so there should be an option to debug server side.
What about adding sourcemaps?

All 2 comments

There's no way to debug using node --debug. Cause there are no sourcemaps and all ran code is transpiled. When you want to debug it's best to just use plain old console.log. Cause it's a combination of client/server rendering only debugging the node.js side wouldn't suffice either way :). If you're looking for issues that can help you understand the codebase take a look at the good for beginners label https://github.com/zeit/next.js/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+for+Beginners%22

I am considering using Next.js in production, so I'd like to be able to debug internals easily without using console.log. Of course, debugging client and server side should be done separately.
The whole project is run in Node.js, so there should be an option to debug server side.
What about adding sourcemaps?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

renatorib picture renatorib  路  3Comments

swrdfish picture swrdfish  路  3Comments

timneutkens picture timneutkens  路  3Comments

jesselee34 picture jesselee34  路  3Comments

rauchg picture rauchg  路  3Comments