Yes, you have to buy a real ESP32/Arduino board to run your code. The cause of the error is because you did not connect any board or else if you are trying to work with arduino without having a physical board you can try a simulator like https://www.tinkercad.com/circuits