我正在尝试在meteor中安装鬼鬼祟祟模块(这个模块位于我的公用文件夹:app/ public /node_node)。
我阅读了答案在这个岗位上,并在server/server.js中添加了以下代码
Meteor.startup ->
path = Npm.require 'path'
fs = Npm.require 'fs'
base = path.resolve '.'
isBundle = fs.existsSync base + '/bundle'
modulePath = base + (if isBundle then '/bundle/static' else '/public') + '/node_modules'
spooky = Npm.require modulePath + '/spooky'但当我运行流星时,我得到:
Error: Cannot find module '/Users/mac/Documents/websites/app/.meteor/local/build/programs/server/public/node_modules/spooky'发布于 2014-02-04 23:31:50
您需要创建一个智能包,以便在应用程序中使用Npm模块。或者,你可以使用流星-npm。
您不能单独使用Npm.require来处理非标准的npm模块,比如spooky。
如果你使用流星-npm,你可以用陨石:mrt add npm安装它。
然后,在您将模块添加到您的Meteor.require("spooky")之后,使用packages.json。您可以在这里查看更多细节:http://meteorhacks.com/complete-npm-integration-for-meteor.html。
这样做的官方方法是制作自己的智能包来包装npm模块。有这样一个包的例子:https://github.com/avital/meteor-xml2js-npm-demo
该示例使用xml2js作为npm模块,但您可以将其名称替换为它的诡异。
然后,您可以将此包添加到您的/packages文件夹中(例如,使用名称spooky),并将其添加到您的meteor add spooky流星项目中。
atmosphere.meteor.com上的包有更多的例子,它们几乎都是这样做的(例如,条带(https://atmosphere.meteor.com/package/stripe))。
发布于 2016-03-04 15:34:53
https://stackoverflow.com/questions/21565679
复制相似问题