Both are fine. You could say, "I haven't seen him FOR years," as well.
If you want to go to the future... then you need 'for.' ('in' doesn't work). I won't/mightn't/shan't see him for years. However, word it differently and 'in' works: I'll see him in a few years.
But for the present and past: I haven't seen him in/for years, I hadn't seen him in/for years.
Also, I didn't see him for years. I think it sounds odd to use 'in' here. With 'didn't' - but perhaps that's just me!