Warning: Accessing non-existent property 'count' of module exports inside circular dependency

(node:10624) Warning: Accessing non-existent property ‘count’ of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)

(node:10624) Warning: Accessing non-existent property ‘findOne’ of module exports inside circular dependency

(node:10624) Warning: Accessing non-existent property ‘remove’ of module exports inside circular dependency
(node:10624) Warning: Accessing non-existent property ‘updateOne’ of module exports inside circular dependency

node --inspect --trace-warnings  
 require('mongodb')

Welcome to Node.js v14.0.0.
Type “.help” for more information.

    internal/process/warning.js:33 (node:10416) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
        at emitCircularRequireWarning (internal/modules/cjs/loader.js:814:11)
        at Object.get (internal/modules/cjs/loader.js:825:5)
        at Object.<anonymous> (D:\迅雷下载\GitHub\control-platform-server-consolidation\common\temp\node_modules\mongodb\lib\operations\db_ops.js:16:42)
        at Module._compile (internal/modules/cjs/loader.js:1185:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
        at Module.load (internal/modules/cjs/loader.js:1034:32)
        at Function.Module._load (internal/modules/cjs/loader.js:923:14)
        at Module.require (internal/modules/cjs/loader.js:1074:19)
        at require (internal/modules/cjs/helpers.js:72:18)
        at Object.<anonymous> (D:\迅雷下载\GitHub\control-platform-server-consolidation\common\temp\node_modules\mongodb\lib\operations\collection_ops.js:5:23)
    writeOut @ internal/process/warning.js:33
    internal/process/warning.js:33 (node:10416) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
        at emitCircularRequireWarning (internal/modules/cjs/loader.js:814:11)
        at Object.get (internal/modules/cjs/loader.js:825:5)
        at Object.<anonymous> (D:\迅雷下载\GitHub\control-platform-server-consolidation\common\temp\node_modules\mongodb\lib\operations\db_ops.js:17:44)
        at Module._compile (internal/modules/cjs/loader.js:1185:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
        at Module.load (internal/modules/cjs/loader.js:1034:32)
        at Function.Module._load (internal/modules/cjs/loader.js:923:14)
        at Module.require (internal/modules/cjs/loader.js:1074:19)
        at require (internal/modules/cjs/helpers.js:72:18)
        at Object.<anonymous> (D:\迅雷下载\GitHub\control-platform-server-consolidation\common\temp\node_modules\mongodb\lib\operations\collection_ops.js:5:23)
    writeOut @ internal/process/warning.js:33
    internal/process/warning.js:33 (node:10416) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
        at emitCircularRequireWarning (internal/modules/cjs/loader.js:814:11)
        at Object.get (internal/modules/cjs/loader.js:825:5)
        at Object.<anonymous> (D:\迅雷下载\GitHub\control-platform-server-consolidation\common\temp\node_modules\mongodb\lib\operations\db_ops.js:18:43)
        at Module._compile (internal/modules/cjs/loader.js:1185:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
        at Module.load (internal/modules/cjs/loader.js:1034:32)
        at Function.Module._load (internal/modules/cjs/loader.js:923:14)
        at Module.require (internal/modules/cjs/loader.js:1074:19)
        at require (internal/modules/cjs/helpers.js:72:18)
        at Object.<anonymous> (D:\迅雷下载\GitHub\control-platform-server-consolidation\common\temp\node_modules\mongodb\lib\operations\collection_ops.js:5:23)
    writeOut @ internal/process/warning.js:33
    internal/process/warning.js:33 (node:10416) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
        at emitCircularRequireWarning (internal/modules/cjs/loader.js:814:11)
        at Object.get (internal/modules/cjs/loader.js:825:5)
        at Object.<anonymous> (D:\迅雷下载\GitHub\control-platform-server-consolidation\common\temp\node_modules\mongodb\lib\operations\db_ops.js:19:46)
        at Module._compile (internal/modules/cjs/loader.js:1185:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
        at Module.load (internal/modules/cjs/loader.js:1034:32)
        at Function.Module._load (internal/modules/cjs/loader.js:923:14)
        at Module.require (internal/modules/cjs/loader.js:1074:19)
        at require (internal/modules/cjs/helpers.js:72:18)
        at Object.<anonymous> (D:\迅雷下载\GitHub\control-platform-server-consolidation\common\temp\node_modules\mongodb\lib\operations\collection_ops.js:5:23)
2 Likes

Hi @masx200_masx200,

Thanks for reporting this issue. This was also raised on NODE-2536, and a fix has been committed. This will be available in the next release of MongoDB Node.js driver (v3.5.7).

Regards,
Wan.

3 Likes

(node:19276) Warning: Accessing non-existent property ‘count’ of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)
(node:19276) Warning: Accessing non-existent property ‘findOne’ of module exports inside circular dependency
(node:19276) Warning: Accessing non-existent property ‘remove’ of module exports inside circular dependency
(node:19276) Warning: Accessing non-existent property ‘updateOne’ of module exports inside circular dependency

exact same problem so, how can i fix it, and fix mongoDB version is already released or not?
mongoose version 5.9.13 and mongoDB atlas 4.2.6, Node.js v 14.2.0
with these dependencies the same error is showing again

Hi @Koushik_Saha, welcome!

MongoDB Node.js driver version 3.5.7 that contains the fix has been released. Based on my test, I can confirmed that this version removed the warnings for circular dependencies.

Looking at mongoose v5.9.13 package.json, it is importing the correct driver version. Also, based on a quick test with mongoose v5.9.13 and node v14.2.0 it is working correctly for me.

As the warning message suggested, could you execute with node --trace-warnings to show where the exact warning was created and post the trace ?

Also, ensure within your node_modules that you have the correct version of the driver v3.5.7. If you’re still encountering the issue, please provide how you’re triggering these warning messages.

Regards,
Wan.

5 Likes

It shows that after run ‘node --inspect --trace-warnings’ and require(mongodb)
But all the errors are same:

(node:6444) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:6444) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
(node:6444) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
(node:6444) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency

PS D:\PlayGround\Social.Forum> node --inspect --trace-warnings
Debugger listening on ws://127.0.0.1:9229/7ce5b368-4c76-42ad-9033-a129e99c5072
For help, see: https://nodejs.org/en/docs/inspector
Welcome to Node.js v14.3.0.
Type ".help" for more information.
> require('mongodb')
<ref *1> [Function (anonymous)] {
  MongoError: [Function: MongoError],
  MongoNetworkError: [Function: MongoNetworkError],
  MongoTimeoutError: [Function: MongoTimeoutError],
  MongoServerSelectionError: [Function: MongoServerSelectionError],
  MongoParseError: [Function: MongoParseError],
  MongoWriteConcernError: [Function: MongoWriteConcernError],
  MongoBulkWriteError: [Function: BulkWriteError],
  BulkWriteError: [Function: BulkWriteError],
  Admin: [Function: Admin],
  MongoClient: [Function: MongoClient] { connect: [Circular *1] },
  Db: [Function: Db] {
    SYSTEM_NAMESPACE_COLLECTION: 'system.namespaces',
    SYSTEM_INDEX_COLLECTION: 'system.indexes',
    SYSTEM_PROFILE_COLLECTION: 'system.profile',
    SYSTEM_USER_COLLECTION: 'system.users',
    SYSTEM_COMMAND_COLLECTION: '$cmd',
    SYSTEM_JS_COLLECTION: 'system.js'
  },
  Collection: [Function: Collection],
  Server: [Function: Server],
  ReplSet: [Function: ReplSet],
  Mongos: [Function: Mongos],
  ReadPreference: [Function: ReadPreference] {
    PRIMARY: 'primary',
    PRIMARY_PREFERRED: 'primaryPreferred',
    SECONDARY: 'secondary',
    SECONDARY_PREFERRED: 'secondaryPreferred',
    NEAREST: 'nearest',
    fromOptions: [Function (anonymous)],
    isValid: [Function (anonymous)],
    primary: ReadPreference { mode: 'primary', tags: undefined },
    primaryPreferred: ReadPreference { mode: 'primaryPreferred', tags: undefined },
    secondary: ReadPreference { mode: 'secondary', tags: undefined },
    secondaryPreferred: ReadPreference { mode: 'secondaryPreferred', tags: undefined },
    nearest: ReadPreference { mode: 'nearest', tags: undefined }
  },
  GridStore: [Function: GridStore] {
    DEFAULT_ROOT_COLLECTION: 'fs',
    DEFAULT_CONTENT_TYPE: 'binary/octet-stream',
    IO_SEEK_SET: 0,
    IO_SEEK_CUR: 1,
    IO_SEEK_END: 2,
    exist: [Function (anonymous)],
    list: [Function (anonymous)],
    read: [Function (anonymous)],
    readlines: [Function (anonymous)],
    unlink: [Function (anonymous)]
  },
  Chunk: [Function: Chunk] { DEFAULT_CHUNK_SIZE: 261120 },
  Logger: [Function: Logger] {
    reset: [Function (anonymous)],
    currentLogger: [Function (anonymous)],
    setCurrentLogger: [Function (anonymous)],
    filter: [Function (anonymous)],
    setLevel: [Function (anonymous)]
  },
  AggregationCursor: [Function: AggregationCursor],
  CommandCursor: [Function: CommandCursor],
  Cursor: [Function: Cursor],
  GridFSBucket: [Function: GridFSBucket],
  CoreServer: [Function: Server] {
    enableServerAccounting: [Function (anonymous)],
    disableServerAccounting: [Function (anonymous)],
    servers: [Function (anonymous)]
  },
  CoreConnection: [Function: Connection],
  Binary: <ref *2> [Function: Binary] {
    BUFFER_SIZE: 256,
    SUBTYPE_DEFAULT: 0,
    SUBTYPE_FUNCTION: 1,
    SUBTYPE_BYTE_ARRAY: 2,
    SUBTYPE_UUID_OLD: 3,
    SUBTYPE_UUID: 4,
    SUBTYPE_MD5: 5,
    SUBTYPE_USER_DEFINED: 128,
    Binary: [Circular *2]
  },
  Code: <ref *3> [Function: Code] { Code: [Circular *3] },
  Map: <ref *4> [Function: Map] { Map: [Circular *4] },
  DBRef: <ref *5> [Function: DBRef] { DBRef: [Circular *5] },
  Double: <ref *6> [Function: Double] { Double: [Circular *6] },
  Int32: <ref *7> [Function: Int32] { Int32: [Circular *7] },
  Long: <ref *8> [Function: Long] {
    fromInt: [Function (anonymous)],
    fromNumber: [Function (anonymous)],
    fromBits: [Function (anonymous)],
    fromString: [Function (anonymous)],
    INT_CACHE_: { '0': [Long], '1': [Long], '-1': [Long] },
    TWO_PWR_16_DBL_: 65536,
    TWO_PWR_24_DBL_: 16777216,
    TWO_PWR_32_DBL_: 4294967296,
    TWO_PWR_31_DBL_: 2147483648,
    TWO_PWR_48_DBL_: 281474976710656,
    TWO_PWR_64_DBL_: 18446744073709552000,
    TWO_PWR_63_DBL_: 9223372036854776000,
    ZERO: Long { _bsontype: 'Long', low_: 0, high_: 0 },
    ONE: Long { _bsontype: 'Long', low_: 1, high_: 0 },
    NEG_ONE: Long { _bsontype: 'Long', low_: -1, high_: -1 },
    MAX_VALUE: Long { _bsontype: 'Long', low_: -1, high_: 2147483647 },
    MIN_VALUE: Long { _bsontype: 'Long', low_: 0, high_: -2147483648 },
    TWO_PWR_24_: Long { _bsontype: 'Long', low_: 16777216, high_: 0 },
    Long: [Circular *8]
  },
  MinKey: <ref *9> [Function: MinKey] { MinKey: [Circular *9] },
  MaxKey: <ref *10> [Function: MaxKey] { MaxKey: [Circular *10] },
  ObjectID: <ref *11> [Function: ObjectID] {
    index: 1063505,
    createPk: [Function: createPk],
    createFromTime: [Function: createFromTime],
    createFromHexString: [Function: createFromHexString],
    isValid: [Function: isValid],
    ObjectID: [Circular *11],
    ObjectId: [Circular *11]
  },
  ObjectId: <ref *11> [Function: ObjectID] {
    index: 1063505,
    createPk: [Function: createPk],
    createFromTime: [Function: createFromTime],
    createFromHexString: [Function: createFromHexString],
    isValid: [Function: isValid],
    ObjectID: [Circular *11],
    ObjectId: [Circular *11]
  },
  Symbol: <ref *12> [Function: Symbol] { Symbol: [Circular *12] },
  Timestamp: <ref *13> [Function: Timestamp] {
    fromInt: [Function (anonymous)],
    fromNumber: [Function (anonymous)],
    fromBits: [Function (anonymous)],
    fromString: [Function (anonymous)],
    INT_CACHE_: { '0': [Timestamp], '1': [Timestamp], '-1': [Timestamp] },
    TWO_PWR_16_DBL_: 65536,
    TWO_PWR_24_DBL_: 16777216,
    TWO_PWR_32_DBL_: 4294967296,
    TWO_PWR_31_DBL_: 2147483648,
    TWO_PWR_48_DBL_: 281474976710656,
    TWO_PWR_64_DBL_: 18446744073709552000,
    TWO_PWR_63_DBL_: 9223372036854776000,
    ZERO: Timestamp { _bsontype: 'Timestamp', low_: 0, high_: 0 },
    ONE: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 0 },
    NEG_ONE: Timestamp { _bsontype: 'Timestamp', low_: -1, high_: -1 },
    MAX_VALUE: Timestamp { _bsontype: 'Timestamp', low_: -1, high_: 2147483647 },
    MIN_VALUE: Timestamp { _bsontype: 'Timestamp', low_: 0, high_: -2147483648 },
    TWO_PWR_24_: Timestamp { _bsontype: 'Timestamp', low_: 16777216, high_: 0 },
    Timestamp: [Circular *13]
  },
  BSONRegExp: <ref *14> [Function: BSONRegExp] {
    BSONRegExp: [Circular *14]
  },
  Decimal128: <ref *15> [Function: Decimal128] {
    fromString: [Function (anonymous)],
    Decimal128: [Circular *15]
  },
  connect: [Circular *1],
  instrument: [Function (anonymous)]
}
> (node:1372) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
    at emitCircularRequireWarning (internal/modules/cjs/loader.js:823:11)
    at Object.get (internal/modules/cjs/loader.js:837:5)
    at Object.<anonymous> (D:\PlayGround\Social.Forum\node_modules\mongodb\lib\operations\db_ops.js:16:42)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)
    at Object.<anonymous> (D:\PlayGround\Social.Forum\node_modules\mongodb\lib\operations\collection_ops.js:5:23)
(node:1372) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
    at emitCircularRequireWarning (internal/modules/cjs/loader.js:823:11)
    at Object.get (internal/modules/cjs/loader.js:837:5)
    at Object.<anonymous> (D:\PlayGround\Social.Forum\node_modules\mongodb\lib\operations\db_ops.js:17:44)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)
    at Object.<anonymous> (D:\PlayGround\Social.Forum\node_modules\mongodb\lib\operations\collection_ops.js:5:23)
(node:1372) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
    at emitCircularRequireWarning (internal/modules/cjs/loader.js:823:11)
    at Object.get (internal/modules/cjs/loader.js:837:5)
    at Object.<anonymous> (D:\PlayGround\Social.Forum\node_modules\mongodb\lib\operations\db_ops.js:18:43)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)
    at Object.<anonymous> (D:\PlayGround\Social.Forum\node_modules\mongodb\lib\operations\collection_ops.js:5:23)
(node:1372) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
    at emitCircularRequireWarning (internal/modules/cjs/loader.js:823:11)
    at Object.get (internal/modules/cjs/loader.js:837:5)
    at Object.<anonymous> (D:\PlayGround\Social.Forum\node_modules\mongodb\lib\operations\db_ops.js:19:46)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)
    at Object.<anonymous> (D:\PlayGround\Social.Forum\node_modules\mongodb\lib\operations\collection_ops.js:5:23)

Hi @Koushik_Saha,

Please check the version of MongoDB Node.js driver (mongodb) being referenced in the project. For example, within node_modules/mongodb/package.json make sure that the version of mongodb package is greater than or equal to 3.5.7.

If you’re using an older version, you could run npm update mongodb to update the package.

Regards,
Wan.

2 Likes

Sir,
i use these packages on my project mongoose v3.5.8 and mongoose works behind with mongodb package v3.5.7

“dependencies”: {
@sendgrid/mail”: “^7.1.1”,
“async”: “^3.2.0”,
“bad-words”: “^3.0.3”,
“bcryptjs”: “^2.4.3”,
“connect-mongo”: “^3.2.0”,
“cookie-parser”: “^1.4.5”,
“dotenv”: “^8.2.0”,
“ejs”: “^3.1.3”,
“express”: “^4.17.1”,
“express-session”: “^1.17.1”,
“lodash”: “^4.17.15”,
“method-override”: “^3.0.0”,
“mongoose”: “^5.9.16”,
“multer”: “^1.4.2”,
socket.io”: “^2.3.0”
}

I waste your so many times but i don’t know how to fix it. i removed node_modules file then run “npm i” but that not work ether. so, what do i do?
That’s the mongoose package.json in node_modules file.–>

“dependencies”: {
“bson”: “^1.1.4”,
“kareem”: “2.3.1”,
“mongodb”: “3.5.7”,
“mongoose-legacy-pluralize”: “1.0.2”,
“mpath”: “0.7.0”,
“mquery”: “3.2.2”,
“ms”: “2.1.2”,
“regexp-clone”: “1.0.0”,
“safe-buffer”: “5.1.2”,
“sift”: “7.0.1”,
“sliced”: “1.0.1”
}

Hi @Koushik_Saha,

Unfortunately I’m unable to reproduce the issue you’re seeing. I copied the dependencies above into package.json, executed npm install with node version 14.3.0 and inspection of mongodb package is as expected.

Could you provide the output of :

  • npm list mongodb
  • npm list -g mongodb

Also, do you have any other node_modules within your application project ?

Regards,
Wan.

1 Like

Sir, These are commands you want me to run.
& i think connect-mongo is the problem right?
If it is what do i do. Because connect mongo v3.2.0 is latest and that uses v3.5.5 mongodb driver not latest one.

PS D:\PlayGround\Social.Forum> npm list mongodb
social.forum@1.0.1 D:\PlayGround\Social.Forum
±- connect-mongo@3.2.0
| -- mongodb@3.5.5 – mongoose@5.9.16
`-- mongodb@3.5.7

PS D:\PlayGround\Social.Forum> npm list -g mongodb
C:\Users\SHARK\AppData\Roaming\npm
`-- (empty)

Hi @Koushik_Saha,

That’s correct, in your project connect-mongo package depends on mongodb package version 3.5.5. You should update the mongodb package that is referenced as a dependency by connect-mongo. You could try to uninstall and re-install back connect-mongo package.

Note that connect-mongo v3.2.0 requirement for mongodb is "^3.1.0", which means you should be able to use the latest stable version of mongodb package. For example, the result of my npm list mongodb :

appName@1.0.0 /path/to/appName

├─┬ connect-mongo@3.2.0
│ └── mongodb@3.5.8 
└─┬ mongoose@5.9.16
  └── mongodb@3.5.7 

Regards,
Wan.

Sir, its done
No error is showing up now.
& sir this is the 1st project (node, mongodb etc.) that i’m working on for IGNOU BCA 6th Sem.
Sir if you have some time just check this and let me know something is wrong or not.
i used some github projects and merge & change some thing.
The Project Website- http://aroot-user-social-forum.herokuapp.com/

Annotation 2020-06-05 145945

1 Like

Hi @Koushik_Saha,

I’m glad that you have managed to solve the dependency problem.

Well done on your first MongoDB/Node project. If you would like to learn more about Node.JS and MongoDB, I’d recommend to enrol in M220JS: MongoDB for JavaScript Developers a free online course from MongoDB University.

If you have any questions, please open a new discussion thread with the relevant information.

Best regards,
Wan.

1 Like

Sir,
actually i thought the if the error was gone everything was all right but no, the session was saved when any one signed in on the site but now after sign in sometime later account automatically signed up but giving an error but the code was same from the beginning i never faced that problem before and maybe the problem is connect-mongo package. how to i fix this. or any alternative for connect-mongo.

And sorry for too many questions.

Hi @Koushik_Saha,

Please open a new topic discussion as your current issue is different to the original question of this topic.
In order to help others help you better, when posting in the new topic please provide:

  • The problem that you’re seeing
  • Minimal reproducible code example so other users able to reproduce the issue that you’re seeing
  • The desired outcome

Regards,
Wan

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.