Codependents and narcissists are similar. They often have a similar upbringing as well, with cold narcissistic parents and being rejected, ignored and neglected. However, there are fundamental differences and the biggest of those is that, where codependents will sacrifice everything to make another person happy, narcissists will not sacrifice anything. Codependents' worth, value and self-esteem comes from them doing things for other people. Narcissists' worth, value and self-esteem comes from other people doing things for them. They are similar but they are opposites in that way, and this is a very fundamental difference.
The drives of the personalities are different. The codependent strives to anticipate and fulfill other people's needs so as to be valued and not abandoned. The narcissist could care less about other people's needs; they don't even really understand that people have needs and they certainly don't attempt to fulfill them. Narcissists fear being abandoned as well, but not because the idea that they failed to meet another person's needs means they're worthless. Far from.
Covert narcissists, which are sometimes called "pathetic" or "vulnerable narcissists" in particular are often confused with codependents. This is why, in my opinion, they are more dangerous than overt narcissists. Covert narcissists do not seem like narcissists at first. They come across as weak, helpless, insecure... As broken, desperate, pathetic and needy. They come across as victims. They are not. They are narcissists.
After being around these people for a while, you realize that everything has to be their way or they will have another breakdown. What looks like insecurity is really self-centeredness. What looks like helplessness is really blame for others, and an excuse not to take responsibility for anything they've done. What looks like desperation and weakness is really an attempt to control and manipulate. They use your pity and sympathy against you, and they are every bit the narcissist that an overt, bullying one is.
Another thing that adds to the confusion is that narcissists actually are codependent themselves, after a fashion. They are dependent on other people for many things, and they foster an environment of enmeshment with others by destroying boundaries between themselves and a partner. However, they do this so that they can get inside the other person's defense mechanisms. The codependent already has poor boundaries to begin with, and has no chance of keeping the narcissist out. Enmeshment with a codependent occurs on accident. A narcissist does it on purpose. In a way, the codependent is the perfect partner for the narcissist: the narcissist wants someone who will set themselves on fire to keep the narcissist warm, and the codependent is perfectly willing to do so. It's the perfect marriage in hell.