I would make a spawner script on a node that would act as a parent to the enemy units, would name the node EnemySpawner or such and have the script spawn enemies under it, thus able to keep track of the amount of children and thus know how many to spawn.
I know you asked how to avoid it, but I honestly think that is probably the best solution. Note that the enemy units themselves can still have their own script that defines their behavior.