How to Avoid Windows Error in Gitbook Serve

In Windows environment

$ gitbook serve

If you edit the markdown after execution

Error: EPERM: operation not permitted, lstat [_book directory name]

This is an urgent measure when the gitbook terminates abnormally with the error.

After starting gitbook serve, once you delete the “_book” folder, for some
reason it works normally after that,

[node.js global installation path] /bin/node_modules/gitbook-cli/bin/gitbook.js

If you add a description to delete the “_book” folder, for example, around the 180th to 194th lines of, gitbook servewill not end abnormally.

  • If you are using bash (git bash, etc.) for your shell
    .description('run a command with a specific gitbook version')
        var args = parsedArgv._.slice(1);
        var kwargs = _.omit(parsedArgv, '$0', '_');
            manager.ensureAndLoad(bookRoot, program.gitbook)
            .then(function(gitbook) {
                if(commandName === 'serve'){
                        require('child_process').execSync('rm -rf _book');
                return commands.exec(gitbook.commands, commandName, args, kwargs);
  • If you are using PowerShell as the shell, make the delete command part as follows
require('child_process').execSync('rm _book -Recurse');

(If you don’t want to make it dependent on the shell, you can delete it with fs.unlink, fs.rmdir, etc.)

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *