title: How to set up nodemon in nextjs + express?
body: <p>My server main file looks like this</p>
  <pre><code>const express = require(&quot;express&quot;);
  const next = require(&quot;next&quot;);
  const port = parseInt(process.env.PORT, 10) || 3000;
  const dev = process.env.NODE_ENV !== &quot;production&quot;;
  
  const app = next({ dev });
  const handle = app.getRequestHandler();
  
  app
    .prepare()
    .then(() =&gt; {
      const server = express();
      server.use(express.json());
      require(&quot;./routes/indexRouter&quot;)(server, app);
      server.all(&quot;*&quot;, (req, res) =&gt; {
        return handle(req, res);
      });
  
      server.listen(port, (err) =&gt; {
        if (err) throw err;
        console.log(&quot;&gt; Ready on http://localhost:&quot; + port);
      });
    })
    .catch((ex) =&gt; {
      console.error(ex.stack);
      process.exit(1);
    });
  
  </code></pre>
  <p>nodemon.json</p>
  <pre><code>{
    &quot;verbose&quot;: true,
    &quot;ignore&quot;: [&quot;node_modules&quot;, &quot;.next&quot;],
    &quot;watch&quot;: [&quot;server/**/*&quot;, &quot;app.js&quot;],
    &quot;ext&quot;: &quot;js json&quot;
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/TuDmX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TuDmX.png" alt="enter image description here" /></a></p>
  <p>nodemon quickly reloads app.js when the file is changed, but nextJS compilation takes a very long time, for this reason I have to wait until everything is compiled before I see the result in the browser.
  I would like to just work with the server without doing mindless re-compilations of the nextJS project</p>