How to debug NextJS API in WebStorm. Also, I am using TypeScript and the app route as it is quite difficult to debug the API using console.log()
.
You can do this like this:
Run > Edit Configurations...
dialog in WebStorm.+
button to add a new configuration, then select Node.js
.Working directory
, choose the root directory of your Next.js project.JavaScript file
field, instead of pointing directly to a file, you will use the Yarn command. Therefore, set the Node interpreter to the Node.js binary path, and in the Node parameters
field, enter the path to the Yarn binary (usually /usr/bin/yarn
or simply yarn
if it's in your system’s PATH).Application parameters
field, type dev
to run Next.js in development mode.OK
.