The reference to 4 needs to be understood as an internal reference number. They are mapped using the GPIO mapping table here https://github.com/nodemcu/nodemcu-firmware/#gpio-old-table-before-build-20141212.
It means that you should wire the DS18B20 signal wire (often yellow in pre-wired waterproof sensors) to the GPIO2 pin.
I made a little one-liner you can include in your scripts if you like that means you can use the normal GPIO numbers.
gpio= {[0]=3,[2]=4,[4]=2,[5]=1,[12]=6,[13]=7,[14]=5,[15]=8,[16]=0}
After this line you can refer to pins like this:
pin=gpio[2] -- connect the signal wire to pin GPIO2
hth
G