[英]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: 在我安装好nodejs和npm,gitbook-cli之后,出现了一个错误。
[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 . 我的nodejs版本和npm分别为v0.10.48,1.3.6,我该怎么办,请帮帮我。
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. 正如此答案所解释的,默认情况下, node.js版本0.10中未启用
const
支持,如果要使用它,则需要--harmony
标志。
As this version of fs-extra package use const
keyword in his index.js file, you got this error. 由于此版本的fs-extra软件包在他的index.js文件中使用
const
关键字,因此出现此错误。
You can have a look at this compatibility table for a summary for const
and let
support by version. 你可以看看这对于总结兼容性表
const
和let
的版本支持。
Just upgrade your node.js version to solve this issue. 只需升级您的node.js版本即可解决此问题。
Also, I don't think it is a good idea to launch gitbook as root user. 另外,我认为以root用户身份启动gitbook并不是一个好主意。
thanks @ TGrif , i upgrade my nodejs ,and its worked. 谢谢@ TGrif,我升级了我的nodejs,它的工作原理。
npm cache clean -f
npm install -g n
n stable
ln -sf /usr/local/n/versions/node/8.0.0/bin/node /usr/bin/node
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.