Search code examples
node.jsasync-awaitbabeljsasync.jsbabel-polyfill

How do I solve ReferenceError: regeneratorRuntime is not defined


I've seen that issue a lot here but none of the solutions worked for me. I'm using NodeJS and had no issue until I changed the project's directory.

Since then I can't get my code to work...

I've included:

import "@babel/polyfill"

I'm using async / await and this is clearly what's causing the issue:

async function process_data(post) {
// my_code
}

If I write the code like that:

const test = async function process_data(post) {
// my code
}

That's working but I can no longer call the process_data method on its own with the parameter (or else, I don't know how do it).

Any idea how I can get that to work?


Solution

  • By tweaking the code I found the answer:

    const my_func = async function process_data(post) {
    // my code
    }
    
    var res = my_func(post_var);