Fatal error: ESP8266WiFi.h: No such file or directory

cannot build project with ESP Async Webserver

platformio.ini

platform = espressif8266
board = nodemcuv2
framework = arduino

lib_deps =
    ESP Async WebServer

Error log:

Compiling .pio\build\nodemcuv2\FrameworkArduino\Esp-frag.cpp.o
Compiling .pio\build\nodemcuv2\FrameworkArduino\Esp-version.cpp.o
*** [.pio\build\nodemcuv2\lib039\WifiManager_ID567\WiFiManager.cpp.o] Error 1
=================================================================================================== [FAILED] Took 1.59 seconds ===================================================================================================
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

> Executing task in folder blink: C:\Users\140bpmdubstep\.platformio\penv\Scripts\platformio.exe run <

Processing nodemcuv2 (platform: espressif8266; board: nodemcuv2; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/nodemcuv2.html
PLATFORM: Espressif 8266 2.3.1 > NodeMCU 1.0 (ESP-12E Module)
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES: toolchain-xtensa 2.40802.191122 (4.8.2), framework-arduinoespressif8266 2.20602.191128 (2.6.2), tool-esptool 1.413.0 (4.13), tool-esptoolpy 1.20800.0 (2.8.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 34 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ESP Async WebServer> 1.2.3 #f13685e
|   |-- <ESPAsyncTCP> 1.2.2 #1547686
|   |-- <Hash> 1.0
Building in release mode
Compiling .pio\build\nodemcuv2\src\main.cpp.o
Generating LD script .pio\build\nodemcuv2\ld\local.eagle.app.v6.common.ld
Compiling .pio\build\nodemcuv2\lib6a6\ESPAsyncTCP\AsyncPrinter.cpp.o
Compiling .pio\build\nodemcuv2\lib6a6\ESPAsyncTCP\ESPAsyncTCP.cpp.o
Compiling .pio\build\nodemcuv2\lib6a6\ESPAsyncTCP\ESPAsyncTCPbuffer.cpp.o
Compiling .pio\build\nodemcuv2\lib6a6\ESPAsyncTCP\SyncClient.cpp.o
Compiling .pio\build\nodemcuv2\lib6a6\ESPAsyncTCP\tcp_axtls.c.o
Compiling .pio\build\nodemcuv2\lib643\Hash\Hash.cpp.o
Compiling .pio\build\nodemcuv2\libec9\ESP Async WebServer\AsyncEventSource.cpp.o
In file included from .pio\libdeps\nodemcuv2\ESP Async WebServer\src\AsyncEventSource.h:31:0,
                 from .pio\libdeps\nodemcuv2\ESP Async WebServer\src\AsyncEventSource.cpp:21:
.pio\libdeps\nodemcuv2\ESP Async WebServer\src/ESPAsyncWebServer.h:35:25: fatal error: ESP8266WiFi.h: No such file or directory

*********************************************************************
* Looking for ESP8266WiFi.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:ESP8266WiFi.h"
* Web  > https://platformio.org/lib/search?query=header:ESP8266WiFi.h
*
*********************************************************************

 #include <ESP8266WiFi.h>
                         ^
compilation terminated.
*** [.pio\build\nodemcuv2\libec9\ESP Async WebServer\AsyncEventSource.cpp.o] Error 1
=================================================================================================== [FAILED] Took 3.07 seconds ===================================================================================================
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

ESP8266 NodeMcu V3 board

Extend your platformio.ini file with one more library. Then it should work.

lib_deps =
    ESP Async WebServer
    ESP8266WiFi
2 Likes

This answer is the suitable to this question :