electron React:停滞在本地主机3000的等待状态

hjqgdpho  于 2022-12-25  发布在  Electron
关注(0)|答案(1)|浏览(200)

我一直在尝试实现电子和React在一起,用下面的package.json

{
"name": "loader",
"version": "0.1.0",
"private": true,
"dependencies": {
  "@testing-library/jest-dom": "^5.16.5",
  "@testing-library/react": "^13.3.0",
  "@testing-library/user-event": "^13.5.0",
  "cross-env": "^7.0.3",
  "electron-is-dev": "^2.0.0",
  "react": "^18.2.0",
  "react-countup": "^6.3.1",
  "react-dom": "^18.2.0",
  "react-icons": "^4.4.0",
  "react-idle-timer": "^5.4.2",
  "react-loader-spinner": "^5.3.3",
  "react-rnd": "^10.3.7",
  "react-router-dom": "^6.4.0",
  "react-scripts": "5.0.1",
  "react-spring": "^9.5.3",
  "styled-components": "^5.3.5",
  "web-vitals": "^2.1.4"
},
"main": "public/main.js",
"homepage": "./",
"scripts": {
  "react-start": "react-scripts start",
  "react-build": "react-scripts build",
  "react-test": "react-scripts test --env=jsdom",
  "react-eject": "react-scripts eject",
  "electron-build": "electron-builder",
  "release": "yarn react-build && electron-builder --publish=always",
  "build": "yarn react-build && yarn electron-build",
  "start": "concurrently \"cross-env BROWSER=none yarn react-start\" \"wait-on http://localhost:3000/ && electron .\""
},
"eslintConfig": {
  "extends": [
    "react-app",
    "react-app/jest"
  ]
},
"browserslist": {
  "production": [
    ">0.2%",
    "not dead",
    "not op_mini all"
  ],
  "development": [
    "last 1 chrome version",
    "last 1 firefox version",
    "last 1 safari version"
  ]
},
"devDependencies": {
  "concurrently": "^7.5.0",
  "electron": "^21.2.3",
  "electron-builder": "^23.6.0",
  "wait-on": "^6.0.1"
}
}

很明显concurrently用于同时运行所有命令。现在,当我执行yarn start时,所有命令都与react-start沿着执行,但即使在http://localhost:3000上的react可用后,wait-on也不再执行,而是被卡住了。最终电子永远不会启动。如果在没有wait-on的情况下测试,那么所有命令都会和电子沿着很好地执行。
有人能指导一下吗?

d7v8vwbk

d7v8vwbk1#

我也遇到了同样的问题,我所需要做的就是把它从wait-on http://localhost:3000改成wait-on http://127.0.0.1:3000
希望能有所帮助!

相关问题