I encountered an `Error: Cannot find module 'react'` error when running `next dev` while setting up vercel/postgres
P粉004287665
2023-08-16 17:07:07
<p>I'm trying to create a table in @vercel/postgres database. The Quick Start Guide document at the link below shows how to create the table and states that you need to run the <code>next dev</code> command. But on the terminal I get the following response: </p>
<blockquote>
<p><em>Cannot find module 'react'. Next.js requires you to include it in 'dependencies' in 'package.json'</em></p>
</blockquote>
<blockquote>
<p><em>throw err;</em> ^</p>
</blockquote>
<blockquote>
<p><em>Error: module 'react' not found</em> ...
code: 'MODULE_NOT_FOUND',*</p>
</blockquote>
<p>I have installed react and react-dom in my package.json file. </p>
<p>I tried deleting node_modules and package_lock.json and then running npm install, but the problem is still not resolved. I'm using node.js version 18.17.1. </p>
<p>Can anyone help? </p>
Check your
package.json
file. If all your libraries are installed, try clearing the cache:Then install the dependencies using the following command:
Then it should run