node.jsnpmgitbook

gitbook-cli install error, gitbook-cli -v cannot be use


after i install the nodejs and npm , gitbook-cli ,there is an error.like this:

[root@vagrant-centos65 vagrant]# gitbook -v

/usr/lib/node_modules/gitbook-cli/node_modules/fs-extra/lib/index.js:3
const assign = require('./util/assign')
^^^^^
SyntaxError: Use of const in strict mode.
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/lib/node_modules/gitbook-cli/lib/config.js:2:10)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
[root@vagrant-centos65 vagrant]# npm -v
1.3.6
[root@vagrant-centos65 vagrant]# node -v
v0.10.48

my nodejs version and npm are v0.10.48 ,1.3.6 ,what should i do ,please help me .


Solution

  • As this answer explain, const support is not enabled by default in node.js version 0.10 and require --harmony flag if you want to use it.

    As this version of fs-extra package use const keyword in his index.js file, you got this error.

    You can have a look at this compatibility table for a summary for const and let support by version.

    Just upgrade your node.js version to solve this issue.

    Also, I don't think it is a good idea to launch gitbook as root user.