That seems a weird error to get from running M5Stack's simple Hello sketch which does not include a poweroff function. (?).
Also I don't know the "ResetReason" sketch that you referred to. Where did you find this ?
(1)OK it seems you have the M5Stack library installed in the correct place.
(2) Is the Espressif ESP32 library installed ? Check: C:\Users\█████\Documents\Arduino\Hardware\espressif\esp32\libraries . If you don't have files there go to M5Stack setup guide and install them.
(3) As PépéMax suggested, in the Arduino IDE, check that the M5Stack is selected as the board that you are using with the IDE. On the Arduino menu go to /Tools/Board . The M5Stack should be set here as the board you are using.
'...some function of the ESP32 does not work yet for the M5Stack library like analogWrite()
Just to clarify, as I understand it, the issue is that not all functions available on Arduino or ESP8266 boards are available at present on ESP32 boards in general - eg: analogWrite();. That is, the problem is not specific to M5Stack boards - it effects all ESP32 boards. Referenced here