diff --git a/pkg/jerryscript/Makefile.jerryscript b/pkg/jerryscript/Makefile.jerryscript
index 504c79590ffbaac3ba106a6c66172bae07199121..a5ca47b2d61d65ec8a3800da3bd4b772d486297b 100644
--- a/pkg/jerryscript/Makefile.jerryscript
+++ b/pkg/jerryscript/Makefile.jerryscript
@@ -6,6 +6,20 @@ EXT_CFLAGS :=-D__TARGET_RIOT
 
 ifeq ($(TOOLCHAIN)_$(BOARD),llvm_native)
   EXT_CFLAGS :=-D__TARGET_RIOT -Wno-conversion
+else ifeq (esp32,$(CPU))
+  # The esp32 C newlib version 2.2.0 has errors when compiling with warnings
+  # that are enabled by jerryscript build system so disable them for this cpu:
+  #  * -Wundef: stdio.h: `__GNU_VISIBLE` and `__BSD_VISIBLE` are not defined
+  EXT_CFLAGS += -Wno-undef -Wno-error=undef
+else ifeq (esp8266,$(CPU))
+  # The esp8266 C newlib version 3.0.0 has errors when compiling with warnings
+  # that are enabled by jerryscript build system so disable them for this cpu:
+  #  * -Wundef
+  #  * -Wconversion
+  #  * -Wsign-conversion
+  EXT_CFLAGS += -Wno-undef -Wno-error=undef
+  EXT_CFLAGS += -Wno-conversion -Wno-error=conversion
+  EXT_CFLAGS += -Wno-sign-conversion -Wno-error=sign-conversion
 endif
 
 .PHONY: all libjerry
@@ -25,7 +39,7 @@ libjerry:
 	 -DJERRY_LIBM=OFF \
 	 -DJERRY_CMDLINE=OFF \
 	 -DHAVE_TIME_H=0 \
-	 -DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \
+	 -DEXTERNAL_COMPILE_FLAGS="$(INCLUDES) $(EXT_CFLAGS)" \
 	 -DMEM_HEAP_SIZE_KB=$(JERRYHEAP)
 
 	"$(MAKE)" -C $(BUILD_DIR) jerry-core jerry-ext jerry-port-default-minimal