I had written this nodejs code shown in the snapshot below:
and then i got the error: (node:17288) Warning: Accessing non-existent property ‘use’ of module exports inside circular dependency.
After a lot of struggles, there are two ways i found to clear the warning message:
- Simply downgrade your node version (i downgraded from node 14 to 10 using nvm)
- Search for the particular keyword in your code that the warning mentioned and see what’s up with it.
So immediately i downgraded from node 14 to 10, the warning disappeared; but i still wanted to continue using node 14, so i tried the second option also; i searched for the keyword “use” mentioned in the error
and i found something interesting in my code at line 4
My God, how did this code at line 4 get here; i don’t remember writing this line of code, to be sure; I go to the required file “routes.js” to see what’s there that warranted me to de-structure “use” in this manner and why didn’t I use it afterall, and behold; routes.js has no such function exported – must have mistakenly typed this or something. I quickly comment out line 4 from my code, revert back my node version to 14 and restarted my server and behold the warning is gone.
Hope this helps someone else fix this problem.