In this sentence, "door" is part of the separable verb doorhalen, which means to continue through the night or to pull an all-nighter. The full expression is een nachtje doorhalen (literally "to pull through a little night"), and in casual speech the verb halen is often dropped, leaving just nachtje door. So "Doe dus geen nachtje door voor je examen" means "So don't pull an all-nighter before your exam."
Why does this happen? Dutch has many separable verbs where a prefix like door can stand alone at the end of a clause. In informal writing and speech, especially on social media or in quick messages, speakers sometimes shorten fixed expressions. Een nachtje doorhalen becomes een nachtje door by analogy with other phrases like de hele nacht door (all through the night). The meaning stays the same: staying up all night. You will also hear een nachtje doortrekken or simply nachtje door in similar contexts.
For practical purposes, treat nachtje door as an informal variant of nachtje doorhalen. When you see door at the end of a sentence without a main verb, check whether it belongs to a separable verb earlier in the clause. Common examples: ik werk de nacht door (I work through the night), hij slaapt de hele dag door (he sleeps all day long). The prefix often adds a sense of "continuing through" or "onward."
If you want to use the expression yourself, the safe, standard form is een nachtje doorhalen. In casual conversation, een nachtje door is fine and widely understood. Avoid using it in formal writing. To practice, try rewriting sentences with separable verbs and see where the prefix lands. For example, Ik haal een nachtje door becomes Ik doe een nachtje door in the shortened version? Actually, the verb doen in your sentence is separate: Doe dus geen nachtje door uses doen as the main verb (do not do an all-nighter), and door is an adverbial particle from the shortened expression. So the structure is doe (imperative of doen) + geen nachtje door (object phrase). This is a colloquial construction, not a standard separable verb with doen.
A good next step is to listen for door at the end of clauses in Dutch media and note when it means "through" versus part of a fixed phrase. Resources like Dutch Fluency or other learner communities can help you see patterns, but always verify with a dictionary or native speaker. Remember that informal shortcuts are common, and context makes the meaning clear.