Not all cables work for flashing
USB cables look identical from the outside but are not all the same inside. Charge-only cables contain just the power wires (VBUS and GND) - they will power your ESP32 but the computer will never see it, so you cannot upload a sketch.
Data cables contain all four wires including D+ and D- which carry the serial communication needed for flashing. If your ESP32 powers up but does not appear in the Arduino IDE port list, swap the cable first - it is the most common cause and takes 10 seconds to rule out.