javascript icon indicating copy to clipboard operation
javascript copied to clipboard

ReferenceError: regeneratorRuntime is not defined

Open amargoCactus opened this issue 5 years ago • 2 comments

Explanation

I'm trying to use yoastseo but but it's giving me the following error:

image

image

Technical info

I'm using laravel 5.7

package.json file:

{
    "devDependencies":  {
        "@babel/cli": "^7.4.4",
        "@babel/core": "^7.4.4",
        "@babel/plugin-transform-runtime": "^7.4.4",
        "@babel/preset-env": "^7.4.4",
        "@babel/runtime-corejs3": "^7.4.4",
        "babel-loader": "^8.0.5",
        "core-js": "3",
        "webpack": "^4.30.0",
        "webpack-cli": "^3.3.2",
        "webpack-merge": "^4.2.1"
        ...
    }
    "dependencies": {
        "@babel/polyfill": "^7.4.4",
        "@babel/runtime": "^7.4.4",
        "yoastseo": "^1.51.0"
        ...
    }
}

babel config (babel.config.js)

module.exports = function (api) {
    api.cache(true);

    const presets = [
        [
            "@babel/env",
            {
                useBuiltIns: "usage",
                corejs: 3
            },
        ],
    ];

    const plugins = [
        ["@babel/plugin-transform-runtime", {
            corejs: 3
        }]
    ];

    return {
        presets,
        plugins
    }
};

amargoCactus avatar May 12 '19 00:05 amargoCactus

I'm using Angular and experienced the same error, seems to be something to do with not having "a global regeneratorRuntime" - https://github.com/parse-community/Parse-SDK-JS/pull/740

Installing the babel polyfill (npm install babel-polyfill) and then adding it to my polyfills.ts solved the issue, not sure how you'd do it in Laravel but hope I've pointed you in the right direction.

01CodeLT avatar May 16 '19 15:05 01CodeLT

For Laravel, you should install 'babel-polyfill' npm install babel-polyfill and then put it at the top of the main js file, 'import "@babel/polyfill";' .

niklaz avatar Oct 02 '19 15:10 niklaz