After node.js is successfully used to connect MongoDB data, an error is thrown. db.collection is not a function.

  node.js, question

After successfully connecting MongoDB data with node.js, I want to write data in the database, but it shows that db.collection is not a function. App.js code is shown in the following figure:

clipboard.png
The error prompt thrown by cmd is shown in the following figure:

clipboard.png

Please be a great god!

This error is found in mongodb’s library, which can be solved only by changing the version of mongodb in node_modules to 2.3.33vision;

"dependencies": {
 "mongodb": "^2.2.33"}

Then:

npm install