This is one of the simple solutions that worked for me:
- Plug out the USB connection with the computer;
- Hold the flash button on the nodemcu/esp8266;
- Plug in the usb connection and quickly release the flash button;
- Now try uploading the sketch.
Thank you.