question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR ReferenceError: regeneratorRuntime is not defined

See original GitHub issue

Expected Behavior

Expect Contentful SDK in Angular 11 project to work against sample space.

Actual Behavior

Browser throws error: core.js:5967 ERROR ReferenceError: regeneratorRuntime is not defined at Object._getEntries (create-contentful-api.js:393) at Object.getEntries (create-contentful-api.js:371) at AppComponent.ngOnInit (app.component.ts:26) at callHook (core.js:2486) at callHooks (core.js:2456) at executeInitAndCheckHooks (core.js:2408) at refreshView (core.js:9194) at renderComponentOrTemplate (core.js:9293) at tickRootContext (core.js:10519) at detectChangesInRootView (core.js:10544)

Possible Solution

Regarding #496, seems is not fixed.

Steps to Reproduce

package.json

{
    "name": "contentful-product-catalog-angular",
    "version": "0.0.0",
    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
    },
    "private": true,
    "dependencies": {
        "@angular/animations": "~11.0.5",
        "@angular/common": "~11.0.5",
        "@angular/compiler": "~11.0.5",
        "@angular/core": "~11.0.5",
        "@angular/forms": "~11.0.5",
        "@angular/platform-browser": "~11.0.5",
        "@angular/platform-browser-dynamic": "~11.0.5",
        "@angular/router": "~11.0.5",
        "contentful": "^8.1.6",
        "rxjs": "~6.6.0",
        "tslib": "^2.0.0",
        "zone.js": "~0.10.2"
    },
    "devDependencies": {
        "@angular-devkit/build-angular": "~0.1100.5",
        "@angular/cli": "~11.0.5",
        "@angular/compiler-cli": "~11.0.5",
        "@types/jasmine": "~3.6.0",
        "@types/node": "^12.11.1",
        "codelyzer": "^6.0.0",
        "jasmine-core": "~3.6.0",
        "jasmine-spec-reporter": "~5.0.0",
        "karma": "~5.1.0",
        "karma-chrome-launcher": "~3.1.0",
        "karma-coverage": "~2.0.3",
        "karma-jasmine": "~4.0.0",
        "karma-jasmine-html-reporter": "^1.5.0",
        "protractor": "~7.0.0",
        "ts-node": "~8.3.0",
        "tslint": "~6.1.0",
        "typescript": "~4.0.2"
    }
}

app.component.ts

import { Component, OnInit } from '@angular/core';
import { createClient } from 'contentful';

const CONFIG = {
  space: 'wl1z0pal05vy',
  accessToken:
    '0e3ec801b5af550c8a1257e8623b1c77ac9b3d8fcfc1b2b7494e3cb77878f92a',
  contentTypeIds: {
    product: '2PqfXUJwE8qSYKuM0U6w8M',
  },
};

@Component({
  selector: 'app-root',
  template: `<div>contentful test</div>`,
})
export class AppComponent implements OnInit {
  private cdaClient = createClient({
    space: CONFIG.space,
    accessToken: CONFIG.accessToken,
  });

  ngOnInit(): void {
    console.log(this.cdaClient);
    this.cdaClient
      .getEntries(
        Object.assign({
          content_type: CONFIG.contentTypeIds.product,
        })
      )
      .then((a: any) => console.log(a));
  }
}

Context

Angular SPA to use Contentful delivery/preview.

Environment

Angular CLI: 11.0.5 Node: 14.8.0 OS: darwin x64

Angular: 11.0.5 Ivy Workspace: Yes

@angular-devkit/architect 0.1100.5 @angular-devkit/build-angular 0.1100.5 @angular-devkit/core 11.0.5 @angular-devkit/schematics 11.0.5 @schematics/angular 11.0.5 @schematics/update 0.1100.5 rxjs 6.6.3 typescript 4.0.5

Chrome Version 87.0.4280.88 (Official Build) (x86_64) Edge Version 88.0.705.29 (Official build) Beta (64-bit) Safari Version 13.1.2 (13609.3.5.1.5)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
pgusocommented, Jan 12, 2021

As a quick fix add the following two lines at the top of the app.component.ts file, you don’t get an error anymore

import "core-js/stable";
import "regenerator-runtime/runtime";
1reaction
marcolinkcommented, Feb 23, 2021

Hello,

I made a new PR addressing this problem. Once it’s approved, I’ll post an update here

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix regeneratorRuntime is not defined?
I have ran into a problem, the error is regeneratorRuntime is not defined while working with React and Parcel bundler.
Read more >
Babel 6 regeneratorRuntime is not defined - Stack Overflow
This error is caused when async/await functions are used without the proper Babel plugins. As of March ...
Read more >
ReferenceError regeneratorRuntime is not defined · Issue #9849
I'm building an SSR template, and when I use @babebl/register and then execute webpack (config), the system reported an error.
Read more >
Parcel, how to fix the `regeneratorRuntime is not defined` error
I run into this problem in a project using Babel as soon as I added an async function, but the problem is the...
Read more >
Babel 7 - ReferenceError regeneratorRuntime is not defined
In one of my ReactJS applications I encountered an error during build with a Yarn/Babel setup: `Babel 7 - ReferenceError: regeneratorRuntime is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found