gpt4 book ai didi

node.js - 为什么 Phantom、Casper 和 Meteor 需要它们自己的可执行文件?

转载 作者:搜寻专家 更新时间:2023-10-31 22:41:14 25 4
gpt4 key购买 nike

Phantom 和 Meteor 是基于 Node 构建的,而 Casper 是基于 Phantom 构建的。为什么它们每个都需要自己单独的可执行文件,而不是您通过 Node.js 需要的库?

(我发现这让它们更难使用,尤其是在 Windows 上。)

最佳答案

phantomjs 完全独立于 node:

http://phantomjs.org/faq.html

Q: Why is PhantomJS not written as Node.js module?

A: The short answer: "No one can serve two masters."

A longer explanation is as follows.

As of now, it is technically very challenging to do so.

Every Node.js module is essentially "a slave" to the core of Node.js, i.e. "the master". In its current state, PhantomJS (and its included WebKit) needs to have the full control (in a synchronous matter) over everything: event loop, network stack, and JavaScript execution.

If the intention is just about using PhantomJS right from a script running within Node.js, such a "loose binding" can be achieved by launching a PhantomJS process and interact with it.

CasperJS 是建立在 Node 之上的,所以它显然不是一个单独的 Node 模块。尽管在那种情况下,您可以使用 SpookyJS带 Node 。

Meteor 确实应该与 Node 更紧密地耦合。有一个类似的框架Derby构建为用作模块。

关于node.js - 为什么 Phantom、Casper 和 Meteor 需要它们自己的可执行文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18038468/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com