PKG-006: mimetype file entry is missing or not first
Epubcheck reports: ERROR(PKG-006): Mimetype file entry is missing or is
not the first file in the archive. This is probably the most common validation error
there is, and one of the easiest to fix.
What it means
An Epub is a zip archive with one special rule: the very first entry must be a file named
mimetype, stored without compression, containing exactly the text
application/epub+zip. Reading systems identify the format by reading those bytes
at a fixed offset, before they unpack anything. If the entry is missing, compressed, or sits
anywhere but first, the file fails validation.
Why it happens
Almost always because the book was unzipped, edited, and zipped back up. Ordinary zip tools
compress everything and order entries however they like. They have no idea about the Epub rule,
so mimetype ends up compressed, in the middle of the archive, or left out entirely.
Some converters and download tools produce the same result.
How to fix it by hand
On Linux or macOS, rebuild the archive from the unpacked book folder with the
mimetype entry first and uncompressed:
zip -X0 ../book.epub mimetype
zip -Xr9 ../book.epub META-INF OEBPS
(Adjust OEBPS to whatever your content folder is called.) On Windows the usual
zip tools give you no control over entry order, which is why this error is so widespread.
The one-click way
The checker finds this error and repairs it automatically: it
rebuilds the archive with a correct mimetype entry first, leaving everything else
byte for byte as it was. Runs in your browser, nothing is uploaded.
container.xml. But stores and strict reading systems reject
the file outright, so it is worth fixing before you publish or convert.