Firebase function for my react app not working

Viewed 858
Error: listen EADDRINUSE: address already in use :::8080
    at Server.setupListenHandle [as _listen2] (net.js:1280:14)`
    at listenInCluster (net.js:1328:12)
    at Server.listen (net.js:1415:7)
    at Object.<anonymous> (/layers/google.nodejs.functions-framework/functions- 
    framework/node_modules/@google-cloud/functions-framework/build/src/index.js:77:8)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

The error shows port 8080 in use that I have checked of my port there is process using port 8080

2 Answers

I discovered this error after upgrading Node from 8 to 10. In my particular case, I was calling app.listen in my app, but Firebase Functions appears to set up the port automatically. Removing app.listen(PORT, () => {}) fixed it for me.

In Create react app you can edit the package.json to be something like this:

"start": "export PORT=3012 react-scripts start",

then when you run npm run start it will boot up the app on port 3012.

you can also run this straight from the terminal like so: PORT=3012 npm run start

Related