代码之家  ›  专栏  ›  技术社区  ›  yiksanchan

FireBase服务:监控端口(5001)已在使用中

  •  1
  • yiksanchan  · 技术社区  · 6 年前

    我建造了这个 React App ,允许用户添加TODO项,并将项标记为已完成/活动。TODO项存储在云FireStore中。

    我想在应用程序上启用全文搜索,一种方法是创建一个云函数,每当云FireStore看到创建操作时,该函数就会将索引写入Algolia。

    在我的app根目录中,我 initialize cloud functions 然后 implement the onTodoAdded function . 做完后,我就跑 firebase serve 在下面 functions 目录并获取错误:

    === Serving from '/Users/evan/source/react-redux-todos'...
    
    i  functions: Preparing to emulate functions.
    Warning: You're using Node.js v10.6.0 but Google Cloud Functions only supports v6.11.5.
    i  hosting: Serving hosting files from: build
    ✔  hosting: Local server: http://localhost:5000
    error: SUPERVISOR error Error: listen EADDRINUSE 127.0.0.1:5001
        at Server.setupListenHandle [as _listen2] (net.js:1335:14)
        at listenInCluster (net.js:1383:12)
        at GetAddrInfoReqWrap.doListen [as callback] (net.js:1509:7)
        at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:61:10)
    error: supervisorPort (5001) is already in use
    i  functions: No HTTPS functions found. Use firebase functions:shell if you would like to emulate other types of functions.
    

    要获得完整的调试日志,请查找 here .

    但是,此命令工作正常: firebase serve --only functions .

    === Serving from '/Users/evan/source/react-redux-todos'...
    
    i  functions: Preparing to emulate functions.
    Warning: You're using Node.js v10.6.0 but Google Cloud Functions only supports v6.11.5.
    i  functions: No HTTPS functions found. Use firebase functions:shell if you would like to emulate other types of functions.
    

    因为上面写着Supervisorport(5001)已经在使用,所以我 lsof -i:5001 却找不到进程。我还关闭了我的笔记本电脑,重新启动,得到同样的错误。

    我发现类似的问题 here 但是没有找到解决方案。

    2 回复  |  直到 6 年前
        1
  •  0
  •   yiksanchan    6 年前

    我仍然不知道原因,但补充说 --port=9000 解决问题。例如, firebase serve --only functions --port=9000 . 学分 restPort (5001) is already in use #142 .

        2
  •  0
  •   Matthew Rideout steverb    6 年前

    在更新到MacOS Mojave 10.14.1之后,我也遇到了同样的错误(10.14没问题)。 error: supervisorPort (5001) is already in use 它把我带进了这个兔子洞,里面有更多的更新和配置,最终使它工作起来。

    1个更新节点包

    我将这些项目更新到这些版本(最新版本)

    • FireBase功能:2.1.0
    • 火力基地:5.5.8

    我删除了node_modules文件夹并重新安装了所有软件包。

    2需要安装FireStore模拟器

    下次我尝试服务时,FireBase给了我这个错误: Setup required, please run: firebase setup:emulators:firestore

    由于我最初在Mac上遇到了奇怪的权限问题,我实际上必须运行 node_modules/.bin/firebase setup:emulators:firestore

    3然后…修复Java运行时问题

    在我下一次发球时,我得到了 firestore: No Java runtime present, requesting install. MAC提供了一个弹出窗口,可以在页面上下载“Java的MAC”。这不是你真正需要的。你真的需要 Java SE Development Kit 启用命令行界面。

    然后…你可能会得到这些错误 下次你要发球时。

    error: restPort (5002) is already in use
    error: SUPERVISOR error Error: listen EADDRINUSE 127.0.0.1:5001
        at Object._errnoException (util.js:1022:11)
        at _exceptionWithHostPort (util.js:1044:20)
        at Server.setupListenHandle [as _listen2] (net.js:1351:14)
        at listenInCluster (net.js:1392:12)
        at GetAddrInfoReqWrap.doListen [as callback] (net.js:1501:7)
        at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:97:10)
    error: supervisorPort (5001) is already in use
    

    但是,尽管出现了这些错误,FireBase仍然以某种方式继续成功服务。它仍然显示我的应用程序结束 http://localhost:5000 .

    希望这有帮助!

    推荐文章