Have you exceeded your settlement size? I doubt that's the case, but I figured I would cover all the bases here. Try placing the generator in a different area, and double check that you have all of the components necessary to build it.
I've found a couple times (what could be a bug) that even if I have all the required pieces I still can't build it if I only have exactly required. So 4/4 adhesive and I can't build it until I get 5/4. Weird
I had this happen. I believe its due to two of the necessary items coming from one junk item. since your resources are counted based on items within junk items. For example the item you want to build requires 1 steel and 1 oil and it says you have them both but they both come from one gas can in your inventory so you cant build the item because you dont actually have 1 steel AND 1 oil you have 1 steel Or 1 oil