之前可以正常通过此处
<code>make debug
</code>
内部调用
<code>gitbook serve </code>
可以正常调试的gitbook的,但是此处出错:
<code>➜ youdao_note_summary git:(master) ✗ make debug -------------------------------------------------------------------------------- Author : crifan.com Version : 20180615 Function: Auto use gitbook to generated files: website/pdf/epub/mobi; upload to remote server; commit to github io repo Run 'make help' to see usage -------------------------------------------------------------------------------- CURRENT_DIR=/Users/crifan/GitBook/Library/Import/youdao_note_summary BOOK_NAME=youdao_note_summary rm -f book.json BookRootPath=/Users/crifan/GitBook/Library/Import CurrentGitbookName=youdao_note_summary rm -rf /Users/crifan/GitBook/Library/Import/youdao_note_summary/debug mkdir -p /Users/crifan/GitBook/Library/Import/youdao_note_summary/debug gitbook serve /Users/crifan/GitBook/Library/Import/youdao_note_summary /Users/crifan/GitBook/Library/Import/youdao_note_summary/debug Live reload server started on port: 35729 Press CTRL+C to quit ... TypeError: Cannot read property 'file' of undefined make: *** [debug] Error 1 </code>
重启Terminal终端
重启Mac
问题依旧。
gitbook serve TypeError: Cannot read property ‘file’ of undefined
Cannot read property ‘file’ of undefined · Issue #1496 · GitbookIO/gitbook
发现是刚才修改:
/Users/crifan/GitBook/Library/Import/youdao_note_summary/.gitignore
加上了:忽略book.json
<code>book.json </code>
-》看起来是:
gitbook会检测到.gitignore的内容,此处忽略了book.json,导致出错的。
-》而之前之所以添加此配置是因为经过:
【已解决】gitbook中book.json中能否把公共部分提取出来
此处的book.json已经是生成的,所以git中就去设置忽略了。
-》既然gitbook不允许这么做,那么就去掉.gitignore中的,忽略book.json的设置吧。
结果:
就正常了:
【总结】
此处gitbook serve出错:
TypeError: Cannot read property ‘file’ of undefined
的原因是:
gitbook检测到.gitignore中忽略掉了(gitbook正常使用时需要调用的)book.json
而此处之所以把明知gitbook要用到的book.json加到.gitignore中,是因为:
在:
【已解决】gitbook中book.json中能否把公共部分提取出来
后,book.json就是生成的文件了,没必要上传git,所以从.gitignore中忽略掉了。
所以此处解决办法是:
确保.gitignore中不要把book.json排除掉,然后gitbook的各种命令,包括gitbook serve就都正常了。
转载请注明:在路上 » 【已解决】gitbook serve出错:TypeError: Cannot read property ‘file’ of undefined