我以前试图让Meteor.require方法工作时遇到了问题,我认为它已经修复但显然没有。虽然我已经升级到Meteor 0.9.0。
任何人都知道如何让Meteor.require方法起作用?
这是我将params传回服务器时在终端上获得的信息
=> App running at: http://localhost:3000/
I20140827-11:08:21.949(-7)? createImage
I20140827-11:08:21.953(-7)? 24890
I20140827-11:08:22.030(-7)? Exception while invoking method 'createImage' TypeError: Object #<Object> has no method 'require'
I20140827-11:08:22.032(-7)? at Meteor.methods.createImage (app/server/server.js:7:21)
I20140827-11:08:22.033(-7)? at maybeAuditArgumentChecks (packages/livedata/livedata_server.js:1492)
I20140827-11:08:22.034(-7)? at packages/livedata/livedata_server.js:643
I20140827-11:08:22.034(-7)? at _.extend.withValue (packages/meteor/dynamics_nodejs.js:56)
I20140827-11:08:22.034(-7)? at packages/livedata/livedata_server.js:642
I20140827-11:08:22.034(-7)? at _.extend.withValue (packages/meteor/dynamics_nodejs.js:56)
I20140827-11:08:22.034(-7)? at _.extend.protocol_handlers.method (packages/livedata/livedata_server.js:641)
I20140827-11:08:22.035(-7)? at packages/livedata/livedata_server.js:541
这是我的Meteor.method:
createImage: function(coords) {
console.log('createImage')
console.log(coords.area);
var gd = Meteor.require('node-gd');
},
我的packages.json文件:
{
"node-gd":"0.2.3"
}
node-gd肯定也有:
me@ubuntu:~/leaderboard/packages/npm/npm/node_modules/node-gd$ ls
binding.gyp build coffee cpp js package.json README.md
答案 0 :(得分:3)
Meteorhacks刚刚发布(我在4小时前谈论)更新的Meteor 0.9
npm包,它被称为meteorhacks:npm
{{3 }}
你应该删除我认为已破坏的先前包(我猜是arunoda:npm
之类的东西)并尝试新的包。
请注意,Meteor.require
已替换为Meteor.npmRequire
!