ESP32 uploading error

Hello, I'm trying to program my ESP32 in Visual Studio Code with PlatformIO. Every time I try to upload code, I get this error. The port that the ESP32 is connected to is found and I am pressing down the boot button to upload. Here is the code and error...

#include <Arduino.h>
#include <FastLED.h>

#define NUM_LEDS 6
#define DATA_PIN 17

CRGB leds[NUM_LEDS];

void setup() { 
    FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
}

void loop() {
    for(int i = 0; i < 6; i++) {
        leds[0] = CRGB::Red;
        FastLED.show();
        delay(500);
    }
    
    for(int i = 0; i < 6; i++) {
        leds[0] = CRGB::Black;
        FastLED.show();
        delay(500);
    }
}
Connecting.........
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: ec:94:cb:4c:b2:f0
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Traceback (most recent call last):
  File "/Users/jeremywon/.platformio/packages/tool-esptoolpy/esptool.py", line 34, in <module>
    esptool._main()
  File "/Users/jeremywon/.platformio/packages/tool-esptoolpy/esptool/__init__.py", line 1004, in _main
    main()
  File "/Users/jeremywon/.platformio/packages/tool-esptoolpy/esptool/__init__.py", line 790, in main
    esp.flash_set_parameters(flash_size_bytes(args.flash_size))
  File "/Users/jeremywon/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 1108, in flash_set_parameters
    self.check_command(
  File "/Users/jeremywon/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 406, in check_command
    val, data = self.command(op, data, chk, timeout=timeout)
  File "/Users/jeremywon/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 375, in command
    p = self.read()
  File "/Users/jeremywon/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 307, in read
    return next(self._slip_reader)
StopIteration
*** [upload] Error 1

Is anyone familiar with this error. Thanks in advance.

I thought the ESP32 has automatic flash mode / reset, but that may not work outside of the arduino IDE i guess. Press the 'flash' button and hold it down, while you press and release the 'reset' button. and then don't touch anything after that.

Mind you this looks like a 'compile' error, not an upload error, to me.

@Deva_Rishi, the new flashing method you described worked! Thanks so much for your help.