GitbookIO / gitbook-cli

GitBook's command line interface

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gitbook install/init fails

jbaskeen opened this issue · comments

I'm trying to install and use gitbook-cli for the first time and am seeing an issue getting it running. I've seen #68 issue but the solutions in the issue don't appear to work for me. I'm not finding any node/npm compatibility details in the docs so I'm not sure if the latest node 8 is supported. However, I'm also seeing the issues with node 6.

Commands:

node -v
npm -v
rm -rf ~/.gitbook
npm i -g gitbook-cli
gitbook --version
gitbook init

Output:

node v8.7.0
npm 5.4.2
/usr/local/bin/gitbook -> /usr/local/lib/node_modules/gitbook-cli/bin/gitbook.js
+ gitbook-cli@2.3.2
added 578 packages in 8.667s
CLI version: 2.3.2
Installing GitBook 3.2.3
undefined ../../../../../var/folders/mc/22vf5c6d69ncltcmpd7vkx8w0000gn/T/tmp-90812CaAhzXdEJqUm/node_modules/gitbook
├── escape-html@1.0.3
├── undefined
├── undefined
├── undefined
├── undefined
├── undefined
├── is@3.2.1
├── undefined
├── undefined
├── undefined
├── undefined
├── undefined
├── object-path@0.9.2
├── undefined
├── undefined
├── undefined
├── extend@3.0.1
├── undefined
├── undefined
├── undefined
├── undefined
├── undefined
├── undefined
├── immutable@3.8.2
├── undefined
├── front-matter@2.2.0
├── undefined (domelementtype@1.1.3, entities@1.1.1)
├── undefined (string-template@0.2.1, xtend@4.0.1)
├── omit-keys@0.1.0 (isobject@0.2.0, )
├── undefined (os-tmpdir@1.0.2)
├── undefined (semver@4.3.6)
├── undefined (etag@1.7.0, statuses@1.2.1, range-parser@1.0.3, , , depd@1.1.1, debug@2.2.0, , http-errors@1.3.1, on-finished@2.3.0)
├── undefined
├── undefined
├── undefined
├── undefined (, , sleuth@0.1.1, astw@1.3.0, through2@0.6.5, escodegen@1.9.0, acorn@0.9.0)
├── undefined (rimraf@2.4.5)
├── js-yaml@3.10.0 (esprima@4.0.0, argparse@1.0.9)
├── read-installed@4.0.3 (debuglog@1.0.1, util-extend@1.0.3, slide@1.1.6, readdir-scoped-modules@1.0.2, read-package-json@2.0.12)
├── undefined (parseurl@1.3.2, livereload-js@2.2.2, qs@5.1.0, debug@2.2.0, faye-websocket@0.10.0, body-parser@1.14.2)
├── undefined
├── undefined (, )
├── undefined
├── undefined
├── undefined (lodash@3.10.1)
├── undefined (deep-extend@0.4.2, , , , , cross-spawn-async@2.2.5, )
├── undefined (lodash@4.17.4)
├── undefined (entities@1.1.1, css-select@1.2.0, htmlparser2@3.8.3, jsdom@7.2.2, lodash@4.17.4)
├── undefined (, gitbook-html@1.3.3, , lodash@4.17.4)
├── undefined (gitbook-html@1.3.3, , lodash@4.17.4)
├── undefined (aws-sign2@0.6.0, tunnel-agent@0.4.3, forever-agent@0.6.1, oauth-sign@0.8.2, caseless@0.11.0, is-typedarray@1.0.0, stringstream@0.0.5, aws4@1.6.0, isstream@0.1.2, json-stringify-safe@5.0.1, tough-cookie@2.2.2, node-uuid@1.4.8, qs@6.1.2, combined-stream@1.0.5, mime-types@2.1.17, bl@1.1.2, hawk@3.1.3, http-signature@1.1.1, har-validator@2.0.6, form-data@1.0.1)
├── undefined (path-is-absolute@1.0.1, inherits@2.0.3, async-each@1.0.1, glob-parent@2.0.0, is-glob@2.0.1, is-binary-path@1.0.1, readdirp@2.1.0, anymatch@1.3.2)
├── undefined (asap@2.0.6, yargs@3.32.0, chokidar@1.7.0)
└── undefined
GitBook version: 3.2.3
�[0;31mError loading version latest: Error: Cannot find module '/Users/James/.gitbook/versions/3.2.3'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at /usr/local/lib/node_modules/gitbook-cli/lib/local.js:103:23
    at _fulfilled (/usr/local/lib/node_modules/gitbook-cli/node_modules/q/q.js:854:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/gitbook-cli/node_modules/q/q.js:883:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/gitbook-cli/node_modules/q/q.js:816:13)
    at /usr/local/lib/node_modules/gitbook-cli/node_modules/q/q.js:877:14
    at runSingle (/usr/local/lib/node_modules/gitbook-cli/node_modules/q/q.js:137:13)�[0m

�[0;31mTypeError: Cannot read property 'commands' of null�[0m

@werne2j discovered that the following steps worked

npm install -g gitbook-cli@2.3.1

cd /usr/local/lib/node_modules/gitbook-cli
rm -rf node_modules
sed -i '' "s^npmi@2.0.1^npmi@1.0.1^g" package.json
npm install

cd ~

gitbook fetch 3.2.2
cd ~/.gitbook/versions/3.2.2/
rm -rf node_modules
npm install

cd ~

mkdir test && cd test
gitbook init

Thanks this worked for me as I was also having an issue with file not found errors during the install of 3.2.2. However I did not need to rm -rf ~/.gitbook/versions/3.2.2/node_modules as it wasn't there.

@jbaskeen THANKS!

Doesn't work at all on Windows.

Is it possible it's failing cuz of nvm? I've tried everything, doesn't seem to be working

Doesn't work at all on Windows.

cd ~/.gitbook/version/3.2.3
npm install

it works

cd ~/.gitbook/version/3.2.3

I do confirm this works, but the path should be:

cd ~/.gitbook/versions/3.2.3

@werne2j discovered that the following steps worked

npm install -g gitbook-cli@2.3.1

cd /usr/local/lib/node_modules/gitbook-cli
rm -rf node_modules
sed -i '' "s^npmi@2.0.1^npmi@1.0.1^g" package.json
npm install

cd ~

gitbook fetch 3.2.2
cd ~/.gitbook/versions/3.2.2/
rm -rf node_modules
npm install

cd ~

mkdir test && cd test
gitbook init

this save me