[Solved] gitbook TypeError: Cannot read property 'file' of undefined

Tonight I came across an issue in gitbook. First of all I want to say that it's a wonderful piece of software and they're trying super hard to build a great service out of gitbook.com to empower self-publishers, but this curious bug had me wondering quite a bit.

The full error message:

(master)⚡ % gitbook serve --debug
Live reload server started on port: 35729
Press CTRL+C to quit ...


TypeError: Cannot read property 'file' of undefined
TypeError: Cannot read property 'file' of undefined
 at /home/jonathan/.gitbook/versions/3.2.2/lib/parse/parseConfig.js:44:19
 at _fulfilled (/home/jonathan/.gitbook/versions/3.2.2/node_modules/q/q.js:834:54)
 at self.promiseDispatch.done (/home/jonathan/.gitbook/versions/3.2.2/node_modules/q/q.js:863:30)
 at Promise.promise.promiseDispatch (/home/jonathan/.gitbook/versions/3.2.2/node_modules/q/q.js:796:13)
 at /home/jonathan/.gitbook/versions/3.2.2/node_modules/q/q.js:604:44
 at runSingle (/home/jonathan/.gitbook/versions/3.2.2/node_modules/q/q.js:137:13)
 at flush (/home/jonathan/.gitbook/versions/3.2.2/node_modules/q/q.js:125:13)
 at _combinedTickCallback (internal/process/next_tick.js:67:7)
 at process._tickCallback (internal/process/next_tick.js:98:9)

The solution for me was, since the most recent version of gitbook creates all missing .md files, to update my .gitignore file.

Probably due to previous versions I had the following contents in it:

tmp
node_modules
_book
book*

Which apparently causes gitbook to absolutely ignore the book.json file.

Now, it's been quite a while since I last touched this book project, but I assume I had a reason for adding book* to my .gitignore, probably because the default export names for pdf and epub start with "book". I checked, they still do.

So if you're having trouble with this, make sure your .gitignore file isn't getting in your way ;)

Tagged with: #git #gitbook

Thank you for reading! If you have any comments, additions or questions, please tweet or toot them at me!