title: Error when building next.js app: Can't resolve 'next/head'
body: <p>I am getting the below error when doing <code>next build</code> in my next.js app, after it's been working fine with just <code>next</code> (or <code>npm run dev</code>).</p>
  
  <p>The error:</p>
  
  <pre><code>$ next build
  The module 'react-dom' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install --save react-dom'
  Creating an optimized production build ...
  
  &gt; Using external babel configuration
  &gt; Location: "../.babelrc"
  Failed to compile.
  
  ./pages/_app.js
  Module not found: Can't resolve 'next/head' in '../pages'
  
  &gt; Build error occurred
  Error: &gt; Build failed because of webpack errors
      at build (.../AppData/Roaming/npm/node_modules/next/dist/build/index.js:7:847)
  </code></pre>
  
  <p>I started my project by cloning Material UI's next.js example and just use that as it seems updated:</p>
  
  <p><a href="https://github.com/mui-org/material-ui/tree/master/examples/nextjs" rel="nofollow noreferrer">https://github.com/mui-org/material-ui/tree/master/examples/nextjs</a></p>
  
  <p>However, thinking I just may of have an outdated or broken build, I re-cloned the next.js example and did <code>next build</code> as well, without modifying any files and I get the same error.</p>
  
  <p>How can I fix this? </p>