gitbook icon indicating copy to clipboard operation
gitbook copied to clipboard

error in using gitbook init

Open harwinvoid opened this issue 9 years ago • 13 comments

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

harwinvoid avatar Jul 12 '17 09:07 harwinvoid

Getting the same issue with on both node 7, 8 and with both yarn and npm.

oblador avatar Jul 12 '17 10:07 oblador

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

grmpyninja avatar Jul 12 '17 11:07 grmpyninja

This seems to a regression in [email protected] caused by https://github.com/GitbookIO/gitbook-cli/pull/60

AaronO avatar Jul 12 '17 11:07 AaronO

Downgrading to 2.3.0 doesn't seem to fix the issue.

ghost avatar Jul 12 '17 11:07 ghost

cd ~/.gitbook/versions/3.2.2 && npm i solved it for me

oblador avatar Jul 12 '17 11:07 oblador

Great! It solved it for both @2.3.0 and @2.3.1

ghost avatar Jul 12 '17 11:07 ghost

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.

saun4app avatar Jul 12 '17 16:07 saun4app

@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).

AaronO avatar Jul 12 '17 16:07 AaronO

Reverting to 2.3.0 worked for me (in Netlify CI environment).

cpsubrian avatar Jul 12 '17 21:07 cpsubrian

This is a duplicate of https://github.com/GitbookIO/gitbook-cli/issues/68 and seems to be rather a gitbook-cli issue to me.

winniehell avatar Jul 13 '17 19:07 winniehell

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

AaronO avatar Jul 14 '17 12:07 AaronO

Thank you @AaronO! :heart: I can confirm this is fixed in gitbook-cli 2.3.2. :sparkles:

winniehell avatar Jul 14 '17 18:07 winniehell

Thank you @AaronO

adiferd avatar Jul 16 '17 03:07 adiferd