I am probably missing something very obvious here, but I keep getting the following error when trying to use Postgres from a newly created React app
Module not found: Can't resolve 'dns' in '/Users/tarek/test/node_modules/pg/lib'
Here are the steps to reproduce:
- Create a fresh React app using create-react-app
- Add the Postgres
module using
npm install pg --save - Add the following line to
App.js:
const { Client } = require('pg'); - Type
npm run startand you'll get the above error.
What am I missing here?
**Node version: v8.12.0
** package.json
{
"name": "test",
"version": "0.1.0",
"private": true,
"dependencies": {
"pg": "^7.4.3",
"react": "^16.5.1",
"react-dom": "^16.5.1",
"react-scripts": "1.1.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}