Cant upload arduino code when ESP8266-01 module is connected
Your problem is that there are two ways of wiring your ESP-01 module to the Arduino:

Wired so the PC has access to it and the Arduino is effectively disabled, and
Wired so the Arduino has access to it

You are wired in configuration 1 at the moment whereby the Arduino is effectively turned off and the USB connection goes direct to the ESP-01. When you try and upload code to the Arduino it's the ESP-01 that the computer is talking to, not the Arduino.
You need to wire it in configuration 2. In this configuration the TX/RX pins of the ESP-01 connect to any two pins of the Arduino except pins 0 and 1, and the RESET pin is not connected to anything. Then you can't talk to the ESP-01 through the serial monitor - instead you have to write code for the Arduino that uses SoftwareSerial to communicate for you.
There are many many tutorials online about communicating between the Arduino and the ESP-01.