Search code examples
node.jsreactjselectronconcurrently

wait-on not moving onto the next command for my electron app using reactJs


I am new to electronjs and I am working on an electron app using ReactJs and I am trying to open the dev server using concurrently and wait-on.

Here is my scripts section of package.json

  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "electron:serve": "concurrently -k \"cross-env BROWSER=none npm start\" \"npm run electron:start\"",
    "electron:build": "npm run build && electron-builder -c.extraMetadata.main=build/main.js",
    "electron:start": "wait-on tcp:3000 && electron .",
  },

And when I run npm run electron:serve, the I'm getting this on my terminal

enter image description here

The command doesn't seem to move on to the next section. And when I run electron:start on a new terminal I'm getting this

enter image description here

I had no problem running this on my old laptop two months back and it is not working now. It works fine when I run npm start and electron ..

I've been stuck on this for a while now and any help would be appreciated.


Solution

  • I will make a guess here. According to the discussions on this issue on GitHub, Node 17 introduced a breaking change that might trigger the error you get:

    Error connecting to TCP host:localhost port:3000 Error: connect ECONNREFUSED ::1:3000
    

    Adding 127.0.0.1 to your script should work:

    "electron:start": "wait-on tcp:127.0.0.1:3000 && electron ."