mainmatter / ember-cli-simple-auth-torii

Ember CLI Addon for the Ember Simple Auth Torii package
https://github.com/simplabs/ember-simple-auth/tree/master/packages/ember-simple-auth-torii
MIT License
7 stars 11 forks source link

"Cannot read property 'env' of undefined" in ember server #15

Closed folz closed 9 years ago

folz commented 9 years ago

After running ember install ember-cli-simple-auth and ember install ember-cli-simple-auth-torii in a new ember-cli app, ember server fails with the titular error message. The error message isn't there and everything runs normally when I don't try to install simple-auth-torii and just use simple-auth by itself.

Looking at the error message, this may be an error in torii itself. In node_modules/torii/ember-addon/index.js#L26, this.app is undefined. Let me know if I should open the issue in the torii repo instead.

➜  groupsapp git:(master) ✗ ember --version
version: 0.2.3
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/#watchman for more info.
node: 0.12.2
npm: 2.7.6
➜  groupsapp git:(master) ✗ ember server
version: 0.2.3
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/#watchman for more info.
Cannot read property 'env' of undefined
TypeError: Cannot read property 'env' of undefined
    at Class.treeForAddon (/home/user/Projects/groupsapp/node_modules/ember-cli-simple-auth-torii/node_modules/torii/ember-addon/index.js:26:46)
    at Class._treeFor (/home/user/Projects/groupsapp/node_modules/ember-cli/lib/models/addon.js:315:31)
    at Class.treeFor (/home/user/Projects/groupsapp/node_modules/ember-cli/lib/models/addon.js:285:19)
    at /home/user/Projects/groupsapp/node_modules/ember-cli/lib/models/addon.js:238:32
    at Array.map (native)
    at Class.eachAddonInvoke (/home/user/Projects/groupsapp/node_modules/ember-cli/lib/models/addon.js:236:22)
    at Class.treeFor (/home/user/Projects/groupsapp/node_modules/ember-cli/lib/models/addon.js:283:20)
    at EmberApp.<anonymous> (/home/user/Projects/groupsapp/node_modules/ember-cli/lib/broccoli/ember-app.js:342:20)
    at Array.map (native)
    at EmberApp.addonTreesFor (/home/user/Projects/groupsapp/node_modules/ember-cli/lib/broccoli/ember-app.js:340:30)
// config/environment.js

/* jshint node: true */

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'groupsapp',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    },

    contentSecurityPolicy: {
      'default-src': "'none'",
      'script-src': "'self' 'unsafe-inline' 'unsafe-eval'",
      'font-src': "'self'",
      'connect-src': "'self'",
      'img-src': "'self'",
      'report-uri':"'localhost'",
      'style-src': "'self' 'unsafe-inline'",
      'frame-src': "'none'"
    },

    torii: {
      providers: {
        'facebook-oauth2': {
          'apiKey': '423779847685624',
          'redirectUri': 'http://localhost:4200/'
        }
      }
    }
  };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {

  }

  return ENV;
};
marcoow commented 9 years ago

Yes, that's in torii as the stack trace shows:

TypeError: Cannot read property 'env' of undefined
    at Class.treeForAddon (/home/user/Projects/groupsapp/node_modules/ember-cli-simple-auth-torii/node_modules/torii/ember-addon/index.js:26:46)
folz commented 9 years ago

Hmm - it looks like npm is installing torii@0.3.2 as a dependency of ember-cli-simple-auth-torii despite its package.json declaring torii@0.3.3

├─┬ ember-cli-simple-auth-torii@0.8.0-beta.1
│ └─┬ torii@0.3.2

It looks like other people have had this error too (#13). Trying @cowboy's solution now gives me the warning message

➜  groupsapp git:(master) ✗ rm -rf node_modules/ember-cli-simple-auth-torii/node_modules/torii
➜  groupsapp git:(master) ✗ npm install torii@0.3.3
npm WARN unmet dependency /home/user/Projects/groupsapp/node_modules/ember-cli-simple-auth-torii requires torii@'0.3.2' but will load
npm WARN unmet dependency /home/user/Projects/groupsapp/node_modules/torii,
npm WARN unmet dependency which is version 0.3.3
torii@0.3.3 node_modules/torii
├── broccoli-string-replace@0.0.2 (broccoli-filter@0.1.12)
└── broccoli-funnel@0.2.3 (walk-sync@0.1.3, symlink-or-copy@1.0.1, mkdirp@0.5.0, minimatch@2.0.4, broccoli-read-compat@0.1.3, core-object@0.0.2)

I'm not sure why npm is still trying to install 0.3.2 when your package.json clearly says 0.3.3, but hopefully this can help you narrow down the problem.

marcoow commented 9 years ago

Install ember-cli-simple-auth-torii from github - that has the torii dependency updated to 0.3.3.

folz commented 9 years ago

Thanks, that worked. For anyone else with this problem,

ember install git+ssh://git@github.com/simplabs/ember-cli-simple-auth-torii

is the command that installed the version from github.

cnemeth commented 9 years ago

thnx