1.問題場景
在 node@14.16.1 下使用第三方模塊 mongoose@5.4.0 鏈接數據庫mongoDB,出現如下warning
(node:6584) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:6584) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
(node:6584) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
(node:6584) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
2. 解決方案
不知道為什么報錯, 應該是版本不兼容,卸載舊版本 mongoose 重新下載高版本 npm i mongoose@6.0.4
,數據庫即可鏈接成功.