I agree with Kim on this — cravings aren't usually caused by a lack of nutrients, but I would still argue that this can also be the case!
As Kim's done such a brilliant job in explaining what usually causes cravings, I'll let you read her answer and will, instead, explain why I believe that cravings can sometimes be your body's way of telling you what nutrients you need.
Cravings And Mineral Or Nutrient Deficiencies
I'm anaemic, so I need much more iron than most people. If I've forgotten to take my iron tablets for a while, I often having cravings I can't explain, such as spinach.
I don't dislike spinach by any means, but it seems a bit odd to crave a bag of it for dinner. If I indulge these cravings, I don't tend to have anything with the spinach, so the only thing I can possibly be craving here is the nutrients in spinach. Spinach is particularly high in iron and vitamin C (the vitamin that helps your body to absorb iron).
I also find that if I've been eating too many carbs, I start to crave high-protein foods such as fish, eggs, nuts, and meat. My body runs better on protein and I always feel better if my diet is protein-heavy, but I can't tell whether it's my body or my thoughts that use cravings to "remind" me what to eat!