possibilities/meteor-node-modules

"exports is not defined"

Closed this issue · 1 comments

The package looks super-helpful so I took it for a test-drive, but I immediately ran into the issue described below. Happy to dig in and do some testing / debugging but I figured I would ping you first in case I am running into a known issue?

(note that I am starting meteor with meteorite, using the auth branch - in case that matters)

When my server code executes this:

NodeModules.setPath("server/node_modules")
awssum = NodeModules.require('awssum')

I get an exports is not defined error:

mrt

Stand back while Meteorite does it's thing

Done installing smart packages

Ok, everything's ready. Here comes Meteor!

[[[[[ ~/aso/dev/www ]]]]]

Running on: http://localhost:3000/

app/server/node_modules/awssum/node_modules/passgen/node_modules/vows/lib/vows/coverage/file.js:2
exports.coverage = function (filename, data) {
^
ReferenceError: exports is not defined
    at app/server/node_modules/awssum/node_modules/passgen/node_modules/vows/lib/vows/coverage/file.js:2:1
    at /Users/hugo/aso/dev/www/.meteor/local/build/server/server.js:107:21
    at Array.forEach (native)
    at Function._.each._.forEach (/Users/hugo/aso/dev/www/.meteor/local/build/server/underscore.js:76:11)
    at run (/Users/hugo/aso/dev/www/.meteor/local/build/server/server.js:93:7)
Exited with code: 1

The problem was that I stored the module files under the meteor project's server directory so it got picked up by Meteor as a plain js file, not as a module.

I am no longer encountering the error after I moved my node_module directory outside of the meteor project. Yay!