简体   繁体   English

如何在流星应用程序中使用除流星nodejs以外的npm nodejs

[英]How to use npm nodejs other than meteor nodejs in a meteor application

This is a spillover of my previous post Running bulk email with nodemailer in Meteor js application How to use npm nodejs other than meteor nodejs in a meteor application. 这是我之前的文章的溢出结果,如何在Meteor js应用程序中使用nodemailer 运行批量电子邮件。如何在流星应用程序中使用除流星nodejs以外的npm nodejs。 I am randomly thinking of how I can use nodemailer because by default meteor 1.4 which I run runs on nodejs version 4.x. 我在随机思考如何使用nodemailer,因为默认情况下,我运行的流星1.4运行在nodejs版本4.x上。 and this version can not be upgraded. 并且此版本无法升级。 I have nodejs version 7.x installed via npm on the same computer. 我在同一台计算机上通过npm安装了nodejs版本7.x。 Since nodemailer runs on version 6.x and above, how do I point the file to use npm node other than meteor node? 由于nodemailer在6.x及更高版本上运行,我如何指向该文件以使用流星节点以外的npm节点? I was advised here to install babel, which I did, but the error persists 建议我在这里安装babel,但我仍然这样做,但错误仍然存​​在

You can not use nodeemailer in meteorjs. 您不能在meteorjs中使用nodeemailer。 so, you need to use meteor packages from atmospherejs. 因此,您需要使用来自amosaljs的流星包。 for example:- mrt:meteor-nodemailer epaminond:nodemailer . 例如: -mrt:meteor-nodemailer epaminond:nodemailer there are many packages available. 有很多可用的软件包。

Another way to tackle this is to get Meteor to save a record in the database for each email to be sent. 解决此问题的另一种方法是让Meteor将要发送的每封电子邮件的记录保存在数据库中。 You create another project in node, using express, or whatever framework you like, which looks at the mongo database for emails to send, and sends those out. 您可以使用express或所需的任何框架在节点中创建另一个项目,该项目查看mongo数据库中要发送的电子邮件,然后将其发送出去。 It will need to update the record in the database to mark that it's sent, so that it won't send it again. 它将需要更新数据库中的记录以将其标记为已发送,以便不再发送。 You could set a timer so that it looks for work every minute, or shorter if you like. 您可以设置一个计时器,使它每分钟查找一次工作,或者根据需要缩短工作时间。

That way this other project can use any version of node you like. 这样,其他项目可以使用您喜欢的任何版本的节点。 It could even live on a different server as long as it can connect to the db. 只要它可以连接到数据库,它甚至可以存在于其他服务器上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM