expressjs / express-expose

Expose raw js, objects, and functions to the client-side (awesome for sharing utils, settings, current user data etc)
MIT License
299 stars 26 forks source link

On application start-up: "TypeError: Cannot set property 'expose' of undefined" #33

Open tamitutor opened 11 years ago

tamitutor commented 11 years ago

My code for requiring expose looks like this:

------------------BEGIN CODE--------------------- var express = require('express') , expose = require('express-expose') , program = require('commander') , cookie = require('cookie') , routes = require('./routes') , api = require('./routes/api.js') , passport = require('passport') , BasicStrategy = require('passport-http').BasicStrategy , config = require('config') ;

program .version('0.0.1') .option('-t, --test', 'Run as a test') .parse(process.argv);

var app = module.exports = express.createServer(); ------------------END CODE---------------------

The specific line in express-expose.js throwing the error is line 44.

Please see the attached image... Screen Shot 2013-03-12 at 10 41 02 AM

jonpacker commented 11 years ago

It looks like you might be using an old version of express that doesn't expose the express app prototype that way that express-expose expects. If you upgrade to express 3 this should fix itself.

lbeschastny commented 9 years ago

According to express-expose Readme.md, latest express-expose@0.3.4 is only compatible with express@4.x:

Using the same patch version for different major releases of express seems like a violation of Semantic Versioning to me.

niftylettuce commented 9 years ago

@lbeschastny pull request welcome

lbeschastny commented 9 years ago

@niftylettuce I don't think that anything could be done about express@2.x/express@3.x.

As for express@3.x/express@4.x, you could re-release latest express-expose under 0.4.0 version, marking current express-expose@0.3.4 release as deprecated (or even unpublishing it). It'll resolve all versioning problems for express@3.x users.

As for pull-request, maintiners usually don't like contributors messing with package version, but if you want, I'll create one. Though, it'll be pointless without either deprecating or unpublishing current express-expose@0.3.4 release.