ESP8266 NodeMCU V3 Pinout
NodeMCU V3 (LoLin), 30-pin board, top view with the USB socket at the bottom. Check your board against its silkscreen before wiring power.
D-numbers are not GPIO numbers
The silkscreen says D1, your code says GPIO5. The pairs above are the whole trick to programming this board without losing an evening. D1 and D2 are the usual I2C pair; D5 to D7 carry SPI.
Boot pins
GPIO0, GPIO2 and GPIO15 must sit at the right levels at power-up: 0 high, 2 high, 15 low. Anything hanging on them has to respect that, which is why an LED on D4 sometimes stops a board from booting.
V3 versus V2
On the LoLin V3 the two pins beside A0 are G and VU (ground and 5 V from USB). On the older Amica V2 those same positions are printed RSV and are not connected, which is the quickest way to tell the boards apart.
Flash pins
SD0 to SD3, CMD and CLK talk to the onboard flash chip. They are broken out for factory use and should be left alone.
Sources and datasheets
This diagram was cross-checked against the manufacturer documentation below plus at least two independent references before publishing. When they disagreed, the manufacturer won.
More boards and plugs live on the pinouts index.