2

[A beginner with Reactjs] What I did:

  1. Everything worked fine
  2. Installed http-proxy-middleware dependency
  3. Now I receive the error below even after removing http-proxy-middleware
  4. Following another answer, also tried: cleaning npm cache, removing package-lock.json, reinstall node-modules (in both server and client folder as I wasn't sure)

error:

require(...) is not a function
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the client@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Any help resolving this? :)

Or Preiss
  • 59
  • 7

1 Answers1

2

There were some changes made recently, check out the latest docs.

The best approach for importing is now:

const { createProxyMiddleware } = require('http-proxy-middleware');
Toby
  • 10,294
  • 6
  • 36
  • 62