Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: _ is not defined with coffescript #7

Closed
dcsan opened this issue May 11, 2014 · 4 comments
Closed

ReferenceError: _ is not defined with coffescript #7

dcsan opened this issue May 11, 2014 · 4 comments

Comments

@dcsan
Copy link

dcsan commented May 11, 2014

I've created a package which uses the collection-helpers package, but i'm getting some very indecipherable errors.

error is around _ not being defined inside collection-helpers*

Ensure dependencies...
W20140511-04:26:12.268(-7)? (STDERR) 
W20140511-04:26:12.268(-7)? (STDERR) /Users/dc/.meteor/tools/43b8566b9f/lib/node_modules/fibers/future.js:173
W20140511-04:26:12.269(-7)? (STDERR)                        throw(ex);
W20140511-04:26:12.269(-7)? (STDERR)                              ^
W20140511-04:26:12.273(-7)? (STDERR) ReferenceError: _ is not defined
W20140511-04:26:12.273(-7)? (STDERR)     at Meteor.Collection.helpers (packages/collection-helpers/collection-helpers.js:6)
W20140511-04:26:12.273(-7)? (STDERR)     at __coffeescriptShare (packages/bot/Chatbots.coffee:19:9)
W20140511-04:26:12.274(-7)? (STDERR)     at packages/bot.js:131:4
W20140511-04:26:12.274(-7)? (STDERR)     at packages/bot.js:191:3
W20140511-04:26:12.274(-7)? (STDERR)     at /Users/dc/dev/shumi/mechat/.meteor/local/build/programs/server/boot.js:155:10
W20140511-04:26:12.274(-7)? (STDERR)     at Array.forEach (native)
W20140511-04:26:12.274(-7)? (STDERR)     at Function._.each._.forEach (/Users/dc/.meteor/tools/43b8566b9f/lib/node_modules/underscore/underscore.js:79:11)
W20140511-04:26:12.275(-7)? (STDERR)     at /Users/dc/dev/shumi/mechat/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8

I tried adding underscore even to my own package:

Package.on_use(function(api) {
    api.export(['Chatbots', 'Botrules']);   
    api.use(['coffeescript', 'underscore', 'collection-helpers']);
    api.add_files(['collections.coffee', 'Chatbots.coffee', 'Botrules.coffee', 'globals.js']);
});

I'm guessing this maybe something coffeescript related :(

following this issue
http://stackoverflow.com/questions/23281235/coffeescript-namespace-exports-in-meteor-custom-packages

I also tried using a separate globals.js

this is with meteor 0.8.1.1

have collection-helpers succesfully been used in other packages?
i guess the next thing is to rewrite everything in vanilla .js >.<

@dburles
Copy link
Owner

dburles commented May 11, 2014

Hmm, it might actually be that I haven't defined api.use('underscore') with collection-helpers' package.js. Would you mind giving that a try?

@dcsan
Copy link
Author

dcsan commented May 11, 2014

yep, that seemed to fix it! i thought underscore was included by default with meteor bootstrapping...

@dcsan
Copy link
Author

dcsan commented May 11, 2014

do you want me to make a PR?

as i'm sure you know just replacing this:
https://github.com/dburles/meteor-collection-helpers/blob/master/package.js#L6

Package.describe({
  summary: 'Collection helpers'
});

Package.on_use(function(api) {
  api.use(['underscore']);
  api.add_files('collection-helpers.js', ['client', 'server']);
});

@dburles
Copy link
Owner

dburles commented May 11, 2014

Thanks @dcsan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants