cometlj / hexo-translate-title

使用Google翻译,百度翻译和有道翻译将Hexo文章中的汉字标题转成英文标题
https://cometlj.github.io
Other
43 stars 17 forks source link

hexo generate时报错「TypeError: Cannot read property 'data' of undefined」 #3

Closed linpeng13 closed 6 years ago

linpeng13 commented 6 years ago

求教,hexo generate时报错TypeError: Cannot read property 'data' of undefined,日志如下:

/Users/linpeng/Documents/linpeng13-github-io/node_modules/hexo-translate-title/lib/util.js:189
                  let title_array = json_str.trans_result.data[0].dst.replace(/\s/g,"-").replace(/(.)\1+/gi,'$1').split("-");
                                                         ^

TypeError: Cannot read property 'data' of undefined
    at Request._callback (/Users/linpeng/Documents/linpeng13-github-io/node_modules/hexo-translate-title/lib/util.js:189:58)
    at Request.self.callback (/Users/linpeng/Documents/linpeng13-github-io/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/Users/linpeng/Documents/linpeng13-github-io/node_modules/request/request.js:1163:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/Users/linpeng/Documents/linpeng13-github-io/node_modules/request/request.js:1085:12)
    at IncomingMessage.g (events.js:292:16)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
linpeng13 commented 6 years ago

尝试以下2种方案,均未解决,故求教

  1. 删除hexo blog目录下所有的.DS_Store 文件; 2.升级使用node v7.2.0版本(原先使用v6.11.2)
cometlj commented 6 years ago

今天刚发布了新版,请重新npm安装即可