meteor-publish-join
meteor-publish-join copied to clipboard
ReferenceError: Meteor is not defined
For some reason I'm getting this error:
W20170120-17:40:14.015(0)? (STDERR) ReferenceError: Meteor is not defined
W20170120-17:40:14.015(0)? (STDERR) at Object.<anonymous> (.....\node_modules\meteor-publish-join\dist\server\index.js:49:5)
W20170120-17:40:14.015(0)? (STDERR) at Module._compile (module.js:409:26)
W20170120-17:40:14.015(0)? (STDERR) at Object.Module._extensions..js (module.js:416:10)
W20170120-17:40:14.015(0)? (STDERR) at Module.load (module.js:343:32)
W20170120-17:40:14.015(0)? (STDERR) at Function.Module._load (module.js:300:12)
W20170120-17:40:14.015(0)? (STDERR) at Module.require (module.js:353:17)
W20170120-17:40:14.015(0)? (STDERR) at require (internal/module.js:12:17)
W20170120-17:40:14.015(0)? (STDERR) at Object.<anonymous> (......\node_modules\meteor-publish-join\dist\index.js:8:15)
W20170120-17:40:14.016(0)? (STDERR) at Module._compile (module.js:409:26)
W20170120-17:40:14.016(0)? (STDERR) at Object.Module._extensions..js (module.js:416:10)
I'm using this in a Meteor project, so I'm not sure where this is coming from.
Any ideas?
hmm? this is very weird. What Meteor version do you use?
I still have no clue why this happens to you. Perhaps could you post the code using this module? maybe it could help figure out the problem.
I will try to create a separate reproduction when I get the chance. Will let you know.
Thanks.
I think I was able to track why the issue occurs.
I created a repo to test this: https://github.com/nunof07/meteor-publish-join-issue1
Although I get a different error (Error: PublishJoin can only be used in a Meteor project
) I think the problem is the same.
If you try to use meteor-publish-join
in a package (and not directly in the Meteor "project") you will get this error.
I started with a meteor create --full
command and added the npm package. When I created the code under the imports
folder everything worked correctly.
When I created a separate package (see https://github.com/nunof07/meteor-publish-join-issue1/tree/master/packages/test) and placed the code there I started to see the error that I mentioned above.
I tried to place a Npm.depends
in the package but it doesn't make any difference.
Oh very interesting, I have never thought about this use-case before. I will find a way to get it worked, thanks for your comment 👍
@nunof07 Are you still looking for a solution to this problem?
The difference could come from that you are importing a different file in your project than you are on the sample project.
If you e.g. are importing 'meteor-publish-join/server'
, which will directly try to load the file https://github.com/nlhuykhang/meteor-publish-join/blob/master/src/server/index.js. The check for the type of the variable Meteor
is only done when importing the plugin as 'meteor-publish-join'
.
For the issue itself, please check that the variable Meteor
exists when importing this module. @nlhuykhang maybe we also have to import Meteor
, like described at https://guide.meteor.com/structure.html#importing-meteor-globals
I don't know if this would still work as an npm package then because meteor/meteor
is not in the npm repository and meteor has their own hack to import all meteor/*
packages from atmosphere ...
If anyone is still interested (please vote), I'll have a look at it.