Since ports commonly are configured as inputs at reset, you will need to add a pull-up resistor.
Then write your setup so that the pin is high before switching to output mode.
Some microcontrollers have internal pull-ups, that are even activated at reset, see the specific data sheet. (Thanks, Juraj. I don't know NodeMCU enough to go in details. Anyway, ...