预渲染服务器错误

时间:2018-07-30 19:24:50

标签: javascript node.js google-chrome

我正在尝试运行Prerender服务器,因为建议使用here

开始script后,我得到了答案:

 D:\xxxxx\React\prerender>node server.js 
 2018-07-30T18:40:56.072Z Starting Prerender
 2018-07-30T18:40:56.074Z Starting Chrome
 2018-07-30T18:40:56.084Z Prerender server accepting requests on port  3000 
 2018-07-30T18:40:56.605Z Started Chrome: Chrome/67.0.3396.99 

到目前为止一切正常。 但是在我发送命令之后:

 curl http://localhost:3000/render?url=https://www.example.com/

我收到一条错误消息:

 2018-07-30T18:41:12.336Z getting https://www.example.com/
 2018-07-30T18:41:12.372Z { Error: Not supported
 at D:\xxxxx\React\prerender\node_modules\chrome-remote-interface\lib\chrome.js:90:30
 at Chrome.handleMessage (D:\xxxxx\React\prerender\node_modules\chrome-remote-interface\lib\chrome.js:289:13)
 at WebSocket.<anonymous> (D:\xxxxx\React\prerender\node_modules\chrome-remote-interface\lib\chrome.js:266:27)
 at emitTwo (events.js:126:13)
 at WebSocket.emit (events.js:214:7)
 at Receiver._receiver.onmessage (D:\xxxxx\React\prerender\node_modules\ws\lib\WebSocket.js:143:54)
 at Receiver.dataMessage (D:\xxxxx\React\prerender\node_modules\ws\lib\Receiver.js:385:14)
 at extension.decompress (D:\xxxxx\React\prerender\node_modules\ws\lib\Receiver.js:354:40)
 at _inflate.flush (D:\xxxxx\React\prerender\node_modules\ws\lib\PerMessageDeflate.js:279:12)
 at afterWrite (_stream_writable.js:464:3) response: { code: -32000, message: 'Not supported' } } 2018-07-30T18:41:12.378Z got 504 in 42ms for https://www.example.com/

我在做什么错了?

更新

我安装了最新版本的Chrome Canary并更新了脚本

 var server = prerender({
 chromeLocation: "c:/Users/xxxxx/AppData/Local/Google/Chrome                     SxS/Application/"
 });
 server.start();

现在Chrome启动出现了问题:

 prerender>node server.js
 2018-07-31T09:50:14.277Z Starting Prerender
 2018-07-31T09:50:14.277Z Starting Chrome
 2018-07-31T09:50:14.280Z Prerender server accepting requests on port 3000
 events.js:183
 throw er; // Unhandled 'error' event
 ^

 Error: spawn c:/Users/xxxxx/AppData/Local/Google/Chrome SxS/Application/ ENOENT
 at _errnoException (util.js:1022:11)
 at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
 at onErrorNT (internal/child_process.js:372:16)
 at _combinedTickCallback (internal/process/next_tick.js:138:11)
 at process._tickCallback (internal/process/next_tick.js:180:9)
 at Function.Module.runMain (module.js:695:11)
 at startup (bootstrap_node.js:188:16)
 at bootstrap_node.js:609:3

关于如何解决该问题的任何想法?

最后

1)将chrome更新为68.0.3440.75 64位

2)server.js而不是(例如README.md中的)

var prerender = require("./lib");
  const server = prerender();
  server.start();

改写为:

var prerender = require("./lib");
var server = prerender();
server.use(prerender.sendPrerenderHeader());
// server.use(prerender.blockResources());
server.use(prerender.removeScriptTags());
server.use(prerender.httpHeaders());

server.start();

顺便说一句      ......      2018-07-31T10:43:55.668Z启动Chrome:Chrome / 68.0.3440.75

现在可以了!

0 个答案:

没有答案