# Serverless-plugin-optimize breaking envkey?!

**URL:** <https://forum.serverless.com/t/serverless-plugin-optimize-breaking-envkey/5479>\
**Category:** Serverless Architectures\
**Tags:** aws, lambda, variables\
**Created:** [August 16, 2018, 10:28pm UTC](https://forum.serverless.com/t/serverless-plugin-optimize-breaking-envkey/5479 "2018-08-16T22:28:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kvarela](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/kvarela/32/2288_2.png) [@kvarela](https://forum.serverless.com/u/kvarela)\
**Post date:** [August 16, 2018, 10:28pm UTC](https://forum.serverless.com/t/serverless-plugin-optimize-breaking-envkey/5479/1 "2018-08-16T22:28:00Z")

</div>

This probably has nothing to do with Envkey, but I’m at a loss and hope you guys know something.

Basically, my serverless (Lambda) function was working fine with [envkey](https://github.com/envkey/envkey-node) (setting an ENV var for ENVKEY in the lambda function config). Then, my lambda bundle size got too big, so I had to start using [serverless-plugin-optimize](https://github.com/FidelLimited/serverless-plugin-optimize) in order to shrink the bundle size so that I could upload it to AWS.

It works locally, but for some reason, after switching to serverless-plugin-optimize, it says my ENVKEY is invalid:  
`TypeError: Cannot create property 'stack' on string 'ENVKEY invalid. Couldn't load vars.'`

My ENVKEY is definitely valid as I’ve tested the same key locally and it works.

Any ideas?
