Starting with 1.6.4, Arduino IDE can be used to program and upload the NodeMCU board by installing the ESP8266 third-party platform package (refer https://github.com/esp8266/Arduino):
- Start Arduino, go to File > Preferences
- Add the following link to the Additional Boards Manager URLs: http://arduino.esp8266.com/stable/package_esp8266com_index.json and press OK button
- Click Tools > Boards menu > Boards Manager, search for ESP8266 and install ESP8266 platform from ESP8266 community (and don't forget to select your ESP8266 boards from Tools > Boards menu after installation)
To install additional ESP8266WiFi library:
- Click Sketch > Include Library > Manage Libraries, search for ESP8266WiFi and then install with the latest version.
After above steps, you should compile the sketch normally.