What have you tried so far? Moth powder and mothballs?
You can buy pheramone moth paper traps you can hang in closets and even put in drawers... https://www.amazon.com/s?k=moth+traps&crid=2MOJL94DRL1O3&sprefix=moth+traps%2Caps%2C228&ref=nb_sb_ss_i_1_10
Have you tried moth balls?
At bedtime, fill your kitchen sink half-full of water and squirt some dish soap in it. Splash and mix it around to create some good suds. Leave it until the next morning, you'll be surprised how many moths will be in it. They seem to be drawn to the soapy water.
First question: What kind of moths are you talking about? Do you mean moths that get into your clothing and make tiny little holes in your wool? Most of the time you don't see them and for those types, follow the above answers. But, I have a feeling you might be talking about moths that you are seeing flying around your house. If so, this is a different type of moth....
OK...this can get bad!!! We had this when we first bought our home and it was awful. You have to find the source. What you really need to do is go through the entire pantry and take EVERYTHING OUT!!!!!!! It sucks, but it is the only way to get rid of them. Once you do that you have to clean and wipe down all surfaces of the pantry because you never know where there are eggs and if anything spilled on your pantry shelves or drawers(especially with kids), they could be living in that too. So go through and remove everything and look in everything. It's not always just flour and rice...it could be from oatmeal, any grain whatsoever and they love NUTS. Any stuff they can get to that is in a box or bag. Then go out and spend some money on some airtight containers. ALSO...find freezer space for all grains. You will have to put the grains away in the freezer for a while and cereals and pasta should be put in those airtight containers. Also, check all your cabinets....not just your pantry. Take everything out of ALL of your cabinets because the moths will lay eggs that become a wormy thing that can be found anywhere inside cabinets. Once the source of food is gone though you will start to see it dissipate. But it will take a little while. This is such an annoyance!! I don't have this problem anymore because I just keep my grains and flours in the freezer always. Good luck!!