error in using gitbook init
I install the latest version of [email protected], but i get a error like below:
➜ workspace gitbook init
Error loading version latest: Error: Cannot find module 'extend'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/harwin/.gitbook/versions/3.2.2/lib/index.js:1:76)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
TypeError: Cannot read property 'commands' of null
my node js version and npm version is:
➜ workspace npm -v
3.10.10
➜ workspace node -v
v6.11.0
Getting the same issue with on both node 7, 8 and with both yarn and npm.
It's not only with gitbook init but with other commands as well.
Tried to use this docker https://hub.docker.com/r/fellah/gitbook/ and I switched between node:6-slim, 8-slim and full 8 and same error while gitbook build as well as gitbook serve
This seems to a regression in [email protected] caused by https://github.com/GitbookIO/gitbook-cli/pull/60
Downgrading to 2.3.0 doesn't seem to fix the issue.
cd ~/.gitbook/versions/3.2.2 && npm i solved it for me
Great! It solved it for both @2.3.0 and @2.3.1
Thanks to @oblador, cd ~/.gitbook/versions/3.2.2 && npm i fixed the issue for gitbook init. However, I still get the same error message for gitbook serve and gitbook build.
Update: Actually, cd ~/.gitbook/versions/3.2.2 && npm i helps get around the issue for 'init', 'serve', and 'build'. I had to run , cd ~/.gitbook/versions/3.2.2 && npm i after installing a new package (at book directory).
Also, @AaronO's comment makes sense. The issues stated after I upgraded to npm@5.
@oblador Thanks for posting that workaround, but ideally we should get it fixed in the core.
It seems like npm@5 no longer installs or can be used as a lib to install deps as we expect it to (and that worked with npm@3).
Reverting to 2.3.0 worked for me (in Netlify CI environment).
This is a duplicate of https://github.com/GitbookIO/gitbook-cli/issues/68 and seems to be rather a gitbook-cli issue to me.
This should now be fixed by the gitbook-cli @ 2.3.2 release and is a duplicate of https://github.com/GitbookIO/gitbook-cli/issues/68
Thank you @AaronO! :heart: I can confirm this is fixed in gitbook-cli 2.3.2. :sparkles:
Thank you @AaronO