gpt4 book ai didi

node.js - nodeJS 的每个包都会在 MeteorJS 上运行吗?

转载 作者:搜寻专家 更新时间:2023-11-01 00:02:54 24 4
gpt4 key购买 nike

我正在试用 Meteor,并爱上了它。我的问题是:

我可以在我的 Meteor 上安装任何 nodeJS 包,例如 NodeMailer 并让它开箱即用吗?如果没有,让它运行的通常步骤是什么?

最佳答案

简短的回答是否定的,Meteor 依赖于 Fibers这打破了与许多包的 native 兼容性。目前,获得一个不使用 Fibers 在 Meteor 中工作的包是逐个完成的。 Here is a recent example

您可以 follow these instructions确保您的包与您的 meteor 应用一起部署。

Here is rationale for why Meteor is built with Fibers大卫·格林斯潘 (David Greenspan) 是 Meteor 的核心开发者之一,强调我的观点:

There's actually no inherent or obvious performance trade-off [between using Fibers or not], so we chose to expose the simpler API (or both).

The Node model is basically your app gets one thread, the event loop. If you want your app to be fast, the request handler had better get off the thread fast! The way it does this in vanilla Node is by finishing and returning, after passing a callback somewhere if there is more work to be done. With fibers, the request handler can instead "yield" when it's doing I/O, so it gets off the thread, but invisibly to the programmer. It's as if there are callbacks happening inside the synchronous calls, but the callback is just the continuation of the program. This is what streamline is trying to simulate, but it happens at the V8 level.

The important point is that Meteor's "synchronous" calls don't block, they yield to the event loop. Whereas normally the event loop would bounce around between whatever callbacks need calling, it instead bounces between whatever functions need further execution.

关于node.js - nodeJS 的每个包都会在 MeteorJS 上运行吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14591182/

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