fivetanley/ember-cli-dotenv

Cannot read property 'options' of undefined

Closed this issue · 17 comments

Not sure if I've missed anything but seems like this.app is undefined inside the config hook in my app?

TypeError: Cannot read property 'options' of undefined
  at Class.module.exports.config (/ember/node_modules/ember-cli-dotenv/index.js:12:27)

Weird, seems to work in the test. I'll try to dig into this. Thanks for reporting!

Thanks @fivetabley. I can only find info on the included hook and not config hook so sorry couldn't help. Look forward to the fix!

@kenips can you try again with 0.3.0, and let me know what version of node and ember-cli you are using? thanks!

Sorry @fivetanley no luck.

# ember -v
version: 0.1.2
node: 0.10.33
npm: 2.1.3

All I did was:

~# mkdir my-app
~# cd my-app
my-app# ember init
...
my-app# nom install ember-cli-dotenv --save-dev
my-app# ember server
version: 0.1.2
Cannot read property 'options' of undefined
...

For me at config() entry point console.log(Object.keys(this)) gives:

[ 'project',
  'registry',
  '_didRequiredBuildPackages',
  'treePaths',
  'treeForMethods' ]

Try 0.3.1. I have no idea how I got this working in a different project before. Probably a fluke. if you look at 6353e4b you can see the change required to get this fixed.

I ran into the error in a new app, and upgrading it fixed it for me.

yeah I was just looking at that - you sure that you can get dotEnv from appConfig? I didn't see that myself. whereas anything declared in environment.js would get passed down. So for me moving the whitelisting to environment.js as ENV['dot-env'] seems reasonable.

yeah, the tests passed so i figured it was working. so clearly there's some work to do to get this working from the config hook. wish I could get at the app somehow... :\

I rolled back the change for now, it seems it works in some people's apps but not others. I'll keep looking into it. :(

0.3.3 is out and seems to fully work in my sample application. hope this fixes it for you @kenips

Note that the first time you access process.env may not have your environment variable the first time around as it gets merged with the first app config, then passed to all the addons like ember-cli-dotenv.

@fivetanley it's not working for me. I see that you've added included block but that should be the default behavior anyway. I see the exact same error as first reported now.

Hello! I have the same problem. I create a new dir, initialize ember, install ember-cli-dotenv from git repo and try to start ember server but I get this error:

➜  lala git:(master) ember s
version: 0.1.2
Cannot read property 'options' of undefined
TypeError: Cannot read property 'options' of undefined
    at Class.module.exports.config (/home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli-dotenv/index.js:13:12)
    at /home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/lib/models/project.js:99:27
    at Array.reduce (native)
    at Project.getAddonsConfig (/home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/lib/models/project.js:97:22)
    at Project.config (/home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/lib/models/project.js:84:29)
    at Class.module.exports.Command.extend.run (/home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/lib/commands/serve.js:26:29)
    at Class.Command.validateAndRun (/home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/lib/models/command.js:86:15)
    at /home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/lib/cli/cli.js:54:22
    at $$$internal$$tryCatch (/home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:470:16)
    at $$$internal$$invokeCallback (/home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:482:17)

0.3.4 is out and returns early if the addon gets included too early without the included hook being called. seems to work ok for me, let me know if it works for you.

Looks good to me! Thanks @fivetanley.

Works perfect! Thanks!