0

I can't get babel to transform my async functions correctly for my Node server. It works fine in development when running nodemon ./src/index.js --exec babel-node babelrc but when I build it with babel -d ./dist ./src -s and start it, it throws this error: ReferenceError: regeneratorRuntime is not defined.

My presets:

{
  "presets": ["es2015", "es2017"]
}

What am I missing?

Note: This is not a duplicate. I'm building a server. I'm not using webpack. Trying to use the answers from here won't work.

baron816
  • 701
  • 4
  • 13
  • 1
    It is a duplicate. Nothing about the question I linked to is specific to Webpack vs server and it's asking about the same error. The answer to that question is the answer to this question. – loganfsmyth Jul 18 '17 at 22:28
  • requiring babel-polyfill doesn't work though. I just get the error `Error: only one instance of babel-polyfill is allowed`, so it's already running. – baron816 Jul 18 '17 at 22:33
  • That sounds like something else in your dependency graph is already loading it, but is likely loading it too late, so `regeneratorRuntime` hasn't been assigned yet. You'll have to look through your dependency graph to figure out where the multiple copies are coming from and what is loading them. It should only be loaded once up front. As it is your question mentions none of that, so it isn't really answerable as-is. – loganfsmyth Jul 18 '17 at 22:36
  • I figured it out. Polyfill was loading automatically in development but not production. So I needed to import it manually for production. Thanks for helping me out @loganfsmyth – baron816 Jul 18 '17 at 22:39
  • Cool, glad you got it worked out. – loganfsmyth Jul 18 '17 at 22:45

0 Answers0