在 Meteor 1.0 中加载 NPM 包? [英] Load NPM package in Meteor 1.0?
问题描述
随着 Meteor 的正式上线,有没有可靠的 NPM 包的使用方法?我正在尝试使用 embed.ly,但我没有看到任何直接的方法.
With the official launch of Meteor, is there a solid way to use NPM packages? I'm trying to use embed.ly but I don't see any straightforward way to do so.
另外,作为一个流星新手,我如何在我的文件中包含包?我没有看到任何要求"或导出"功能.
Also, as a meteor novice, how do I include packages in my files? I don't see any 'require' or 'exports' functions.
谢谢!
推荐答案
可以安装meteorhacks:npm
meteor add meteorhacks:npm
meteor
Meteor 将停止.然后你可以编辑新的 package.json 文件
Meteor will then stop. You can then edit the new package.json file
{
"request" : "2.33.0"
}
然后当你启动 Meteor 时,它会为你安装 npm 模块.
Then when you start Meteor it will install the npm modules for you.
用法如下(使用 Meteor.npmRequire
而不是 require
)
Usage would as follows (use Meteor.npmRequire
instead of require
)
request = Meteor.npmRequire("request");
这篇关于在 Meteor 1.0 中加载 NPM 包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!