I have not looked up the history of the word other than to google it, where it is shown to be derived from the Greek pepon via Latin and then French, where it was nasalized to “popon”, with an English suffix, -kin, related to German -chen, being a diminutive. So the original form was nasalized but probably without an -m-.
Now, what evidence do I have for this, without actually going into etymological dictionaries? Simple. The normal term of affection based on the word is “punkin”, not “pumpkin”, although people who have learned that the spelling pronunciation is the “correct” one may advance it to “pumpkin”. Just as first names with a -th- that was added in long after the names were common in English came to be pronounced as if the -th- represented an interdental fricative as in ’frothy’. Where before they were pronounced and spelled with just a -t-, the spelling pronunciation altered the way the words are pronounced. Nevertheless, the nicknames based on these names, because they are ancient forms in the language, keep the -t- pronunciation e.g. Tony for Anthony, Kate for Catherine, Matt for Matthew, Ted for Theodore, Betty for Elizabeth, and on and on.