sst: Config Top-level await is not available in the configured target environment ("node14")

Hey all, first of all, thank you for this amazing framework. Ran into an issue today with @serverless-stack/node@^1.15.16

✘ [ERROR] Top-level await is not available in the configured target environment ("node14")

    node_modules/@serverless-stack/node/config/index.js:17:0:
      17 │ await storeSecretsInConfig();
         ╵ ~

for time beeing a workaround is to use SST_PARAM_${MY_PARAM} env var

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 8
  • Comments: 16 (6 by maintainers)

Most upvoted comments

@LennoxSears apparently you should configure your function construct’s bundle: { format: 'esm' }. Otherwise it’s set to node14 and cjs, according to the findings reported in #1818

If you have already set it in some global scope (app or stack level), make sure you’re not overwritting it in a narrower scope (stack or function level). I was facing the same problem, even though bundle: { format: 'esm' } was set by default at the app level, I had naively set bundle: true while debugging another error related to bundle config. This made my bundle default to node14.

Also, just in case you’re setting the bundle attribute in app or stack defaults, double-check that code is run before you instantiate a function that needs it.