Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: regeneratorRuntime is not defined #717

Closed
dplewis opened this issue Jan 11, 2019 · 7 comments · Fixed by #740
Closed

ReferenceError: regeneratorRuntime is not defined #717

dplewis opened this issue Jan 11, 2019 · 7 comments · Fixed by #740

Comments

@dplewis
Copy link
Member

dplewis commented Jan 11, 2019

Using parse through CDN or npm install parse@version works

I get the following error ReferenceError: regeneratorRuntime is not defined

If I try to run get the bleeding edge in a node project

npm install parse-community/Parse-SDK-JS.git#master --save

or

build it myself and copy parse.min.js from the dist folder into a simple html file.

I don't know much about babel to fix the issue

@farhan-syed
Copy link

Also have this issue, did you find a solution?

@dplewis
Copy link
Member Author

dplewis commented Feb 14, 2019

I haven't you can try playing around with babel to see if you can get it to work

@agoldis
Copy link

agoldis commented Feb 14, 2019

Facing the same issue with [email protected]

https://github.com/parse-community/Parse-SDK-JS/blob/master/gulpfile.js#L18 specifies @babel/plugin-transform-runtime configuration option:

regenerator: false

That instructs babel to transpile async functions into a code that assumes existence of globally defined regeneratorRuntime.

When you start to use the SDK in a project that does not define a global regeneratorRuntime you'll bump into the exception.

Workarounds

There are some workarounds, but appropriate solution highly depends on your project's specific configuration>

  1. Manually include regeneratorRuntime
    Use https://www.npmjs.com/package/regenerator-runtime and make sure the following code is executed before Parse is initialized:
import regeneratorRuntime from 'regenerator-runtime/runtime';
window.regeneratorRuntime = regeneratorRuntime;
  1. Use babel to try and inject the polyfill
    Use @babel/polyfill together with @babel/preset-env + customize the option useBuildIns to inject required polyfills. That's quite tricky, though and very implicit.

  2. Use [email protected]

For maintainers

If there's no specific reason to use this option here, I would suggest to set it to true. That will cause babel to use @babel/runtime/regenerator instead of a global variable, which is much easier to set up (as described in generatorAliasing)

@robertoin
Copy link

Why does this error appear? Everything was working fine to me last week and now I have this issue too.

@dovk
Copy link

dovk commented Feb 17, 2019

Same here - I uninstalled [email protected] and installed [email protected] --exact and it's back to normal

@fmendoza
Copy link

Revert to 2.1.0 is the workaround for now.

@brianyyz
Copy link

For newbies to the Parse JS SDK (like me) I reverted to the 2.1.0 level of the parse.min.js script by retrieving it from:

https://npmcdn.com/[email protected]/dist/parse.min.js

placed it in a local js directory and updated the script tag to refer to it instead of the npmcdn server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants