To Seed a MongoDB Database with Dummy Data

Hi All,

My requirement is to load dummy data in new MongoDB Atlas Cluster and I am getting error when I try to run the script mentioned in the below link. Could you please suggest on how to overcome this and seed the DB.

How to Seed a MongoDB Database with Fake Data | MongoDB

… Uncaught:
Error: Cannot find module ‘faker’
Require stack:

Have you installed the required module faker?

The blog does not seem to mentioned that you have to install it. But like any .js module it must be installed.

You could also take a look at


Hello @Hendry_Ding and welcome to the MongoDB community forums.

I’m not a Node.js person, but that error usually means that you haven’t installed the Node module. Did you run npm install faker@5.5.3 yet? Note that this Node package was purposely broken by its creator a while back so you don’t want the latest version. Once you install the module you should have better luck in running things,


Thank You Doug & Steeve.
I am running the script from mongosh (V1.5.4) from my windows laptop. So how do i do “npm install”.

Also is there any other ways to perform the dummy data loading. Say i require a data of 5 to 10GB.

npm install is ran from your operating system prompt and not from inside mongosh. Once you install the package then you would run node <scriptname> from the command line, You need to make sure that the script has a valid connection string for your MongoDB instance in it for it to run.

Steeve mentions mjeneratejs in his post which is anohter NodeJS package that generates JSON data that could be imported into MongoDB.

1 Like

Thank You Doug.

Was able to overcome all the hiccups and successfully run the below script. Thank you once again for the support.

[How to Seed a MongoDB Database with Fake Data | MongoDB]


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