Node mongodb: Error: connection closed due to parseError

前端 未结 2 594
挽巷
挽巷 2021-02-07 21:48

Using the native \'mongodb\' npm package, I\'m receiving

Error: connection closed due to parseError

When making a very basic query:

         


        
相关标签:
2条回答
  • 2021-02-07 22:04

    For people who are using mongoose instead mongodb can check in the following location for the same.

    /node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection

    0 讨论(0)
  • 2021-02-07 22:09

    Answering my own question to hopefully stop the next person from tearing their hair out:

    As noted here, this error message is useless and doesn't relate to the actual problem. The production Mongo driver throws away all errors in a catch block.

    To find what the error actually is:

    • open your node_modules/mongodb

    • find server.js

    • look for mongoReply.parseBody

    • log the err to see something actually useful.

    In my case:

    ReferenceError: collection is not defined
    

    Edit: Node MongoDB native 1.4 is now stable, and includes a fix to this bug.

    0 讨论(0)
提交回复
热议问题