Is IDE 1.8.19 installed on the same system? If not or if the IDE 1.8.19 installation is a portable installation, compare the versions of the board packages.
PS
You did not follow the instructions to use code tags.
The two versions of the IDE share the same board package installation; exception would be the portable installation of IDE 1.8.19. So if it worked in IDE 1.x it should work in IDE 2.x.
I've compiled your original sketch for nodeMCU1.0 12E without any errors (IDE 2.3.3, ESP8266 board package 3.1.2).
FQBN: esp8266:esp8266:nodemcuv2
Using board 'nodemcuv2' from platform in folder: C:\Users\bugge\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2
Using core 'esp8266' from platform in folder: C:\Users\bugge\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2
...
...
. Variables and constants in RAM (global, static), used 28100 / 80192 bytes (35%)
║ SEGMENT BYTES DESCRIPTION
╠══ DATA 1496 initialized variables
╠══ RODATA 948 constants
╚══ BSS 25656 zeroed variables
. Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 59747 / 65536 bytes (91%)
║ SEGMENT BYTES DESCRIPTION
╠══ ICACHE 32768 reserved space for flash instruction cache
╚══ IRAM 26979 code in IRAM
. Code in flash (default, ICACHE_FLASH_ATTR), used 236084 / 1048576 bytes (22%)
║ SEGMENT BYTES DESCRIPTION
╚══ IROM 236084 code in flash