TypeError: db.collection is not a function
出现以下错误时:
G:\nodejs\login\node_modules\mongodb\lib\mongo_client.js:797
throw err;
^
TypeError: db.collection is not a function
at findRestaurants (G:\nodejs\login\app.js:22:19)
at G:\nodejs\login\app.js:35:3
at args.push (G:\nodejs\login\node_modules\mongodb\lib\utils.js:404:72)
at G:\nodejs\login\node_modules\mongodb\lib\mongo_client.js:255:5
at connectCallback (G:\nodejs\login\node_modules\mongodb\lib\mongo_client.js:933:5)
at G:\nodejs\login\node_modules\mongodb\lib\mongo_client.js:794:11
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
解决方案:
项目包的package.json文件中,将以下依赖项中的“mongodb”的值修改为以下值即可(“^2.2.33”)
并重新再目录下执行 npm install语句