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.

๐Ÿ› Bug Report: "ReferenceError: $RefreshReg$ is not defined" when starting local backend plugin

See original GitHub issue

๐Ÿ“œ Description

Iโ€™m upgrading a local plugin + Backstage app to 1.7, and started seeing the following error when I run yarn workspace backend start.

ReferenceError: $RefreshReg$ is not defined

It appears to be related to react-refresh and/or react-refresh-webpack-plugin? Iโ€™m at a bit of a loss on how to debug this - Iโ€™ve been trying re-installing all my node modules, cleaning the workspace, etc, but nothing seems to be working. I was surprised that anything related to react-refresh would run on a backend plugin. My only wild guess is that the backstage-cli is not excluding react-refresh-webpack-plugin for backend plugins after this work? https://github.com/backstage/backstage/pull/10394

๐Ÿ‘ Expected behavior

yarn workspace backend start successfully starts.

๐Ÿ‘Ž Actual Behavior with Screenshots

Full error:

/code/aws-for-backstage/personal-backstage-app/packages/backend/dist/main.js:422
/******/ 			throw e;
         			^

ReferenceError: $RefreshReg$ is not defined
    at eval (webpack-internal:///../../plugins/aws-proton-backend/dist/index.cjs.js:206:1)
    at Object.../../plugins/aws-proton-backend/dist/index.cjs.js (/code/aws-for-backstage/personal-backstage-app/packages/backend/dist/main.js:118:1)
    at __webpack_require__ (/code/aws-for-backstage/personal-backstage-app/packages/backend/dist/main.js:419:33)
    at fn (/code/aws-for-backstage/personal-backstage-app/packages/backend/dist/main.js:579:21)
    at eval (webpack-internal:///./src/plugins/scaffolder.ts:11:102)
    at Module../src/plugins/scaffolder.ts (/code/aws-for-backstage/personal-backstage-app/packages/backend/dist/main.js:85:1)
    at __webpack_require__ (/code/aws-for-backstage/personal-backstage-app/packages/backend/dist/main.js:419:33)
    at fn (/code/aws-for-backstage/personal-backstage-app/packages/backend/dist/main.js:579:21)
    at eval (webpack-internal:///./src/index.ts:11:77)
    at Module../src/index.ts (/code/aws-for-backstage/personal-backstage-app/packages/backend/dist/main.js:19:1)

Relevant snippet from packages/backend/dist/main.js where I found RefreshReg:

var Router__default = /*#__PURE__*/ _interopDefaultLegacy(Router);\n_c = Router__default;\nvar fs__default = /*#__PURE__*/ _interopDefaultLegacy(fs);\nclass AwsProtonApi {....ctx.logger.info(`Successfully created service ${resp.service.arn}`);\n                ctx.output(\"arn\", `${resp.service.arn}`);\n            }\n        }\n    });\n};\nexports.createAwsProtonServiceAction = createAwsProtonServiceAction;\nexports.createRouter = createRouter; //# sourceMappingURL=index.cjs.js.map\nvar _c;\n$RefreshReg$(_c, \"Router__default\");

Relevant snippet from plugins/aws-proton-backend/dist/index.cjs.js:

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
var Router__default = /*#__PURE__*/_interopDefaultLegacy(Router);
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

class AwsProtonApi {
....
        ctx.logger.info(`Successfully created service ${resp.service.arn}`);
        ctx.output("arn", `${resp.service.arn}`);
      }
    }
  });
};

exports.createAwsProtonServiceAction = createAwsProtonServiceAction;
exports.createRouter = createRouter;
//# sourceMappingURL=index.cjs.js.map

๐Ÿ‘Ÿ Reproduction steps

If it helps, this is how Iโ€™m setting up my workspace: https://github.com/awslabs/aws-proton-plugins-for-backstage/blob/main/docs/developing.md

๐Ÿ“ƒ Provide the context for the Bug.

No response

๐Ÿ–ฅ๏ธ Your Environment

$ yarn backstage-cli info
yarn run v1.22.18
$ /home/ANT.AMAZON.COM/liguori/code/aws-for-backstage/personal-backstage-app/node_modules/.bin/backstage-cli info
OS:   Linux 5.15.0-52-generic - linux/x64
node: v14.21.0
yarn: 1.22.18
cli:  0.20.0 (installed)
backstage:  1.7.1

Dependencies:
  @backstage/app-defaults                          1.0.7
  @backstage/backend-common                        0.15.2
  @backstage/backend-plugin-api                    0.1.3
  @backstage/backend-tasks                         0.3.6
  @backstage/catalog-client                        1.1.1
  @backstage/catalog-model                         1.1.2
  @backstage/cli-common                            0.1.10
  @backstage/cli                                   0.20.0
  @backstage/config-loader                         1.1.5
  @backstage/config                                1.0.3
  @backstage/core-app-api                          1.1.1
  @backstage/core-components                       0.11.2
  @backstage/core-plugin-api                       1.0.7
  @backstage/dev-utils                             1.0.7
  @backstage/errors                                1.1.2
  @backstage/integration-react                     1.1.5
  @backstage/integration                           1.3.2
  @backstage/plugin-api-docs                       0.8.10
  @backstage/plugin-app-backend                    0.3.37
  @backstage/plugin-auth-backend                   0.17.0
  @backstage/plugin-auth-node                      0.2.6
  @backstage/plugin-catalog-backend                1.5.0
  @backstage/plugin-catalog-common                 1.0.7
  @backstage/plugin-catalog-graph                  0.2.22
  @backstage/plugin-catalog-import                 0.9.0
  @backstage/plugin-catalog-node                   1.2.0
  @backstage/plugin-catalog-react                  1.2.0
  @backstage/plugin-catalog                        1.6.0
  @backstage/plugin-github-actions                 0.5.10
  @backstage/plugin-org                            0.5.10
  @backstage/plugin-permission-common              0.7.0
  @backstage/plugin-permission-node                0.7.0
  @backstage/plugin-permission-react               0.4.6
  @backstage/plugin-proxy-backend                  0.2.31
  @backstage/plugin-scaffolder-backend             1.7.0
  @backstage/plugin-scaffolder-common              1.2.1
  @backstage/plugin-scaffolder                     1.7.0
  @backstage/plugin-search-backend-module-pg       0.4.1
  @backstage/plugin-search-backend-node            1.0.3
  @backstage/plugin-search-backend                 1.1.0
  @backstage/plugin-search-common                  1.1.0
  @backstage/plugin-search-react                   1.2.0
  @backstage/plugin-search                         1.0.3
  @backstage/plugin-tech-radar                     0.5.17
  @backstage/plugin-techdocs-backend               1.4.0
  @backstage/plugin-techdocs-module-addons-contrib 1.0.5
  @backstage/plugin-techdocs-node                  1.4.1
  @backstage/plugin-techdocs-react                 1.0.5
  @backstage/plugin-techdocs                       1.3.3
  @backstage/plugin-user-settings                  0.5.0
  @backstage/release-manifests                     0.0.6
  @backstage/test-utils                            1.2.1
  @backstage/theme                                 0.2.16
  @backstage/types                                 1.0.0
  @backstage/version-bridge                        1.0.1

๐Ÿ‘€ Have you spent some time to check if this bug has been raised before?

  • I checked and didnโ€™t find similar issue

๐Ÿข Have you read the Code of Conduct?

Are you willing to submit PR?

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
clareliguoricommented, Nov 11, 2022

That did indeed fix the issue, thanks!

0reactions
clareliguoricommented, Nov 10, 2022

Ahhhhhh thank you for finding that! This repo went through a LOT of hacking to try to get things working initially, so I think itโ€™s probably just left over from that. Will confirm that removing that fixes things

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError: $RefreshReg$ is not defined - Stack Overflow
In my case, this error was happening when overwriting Webpack's mode option. After removing the line below I stopped receiving the error.
Read more >
[Solved]-ReferenceError: $RefreshReg$ is not defined-Reactjs
You can try worker-plugin instead of worker-loader. I have been running into the same issue for a long time before trying worker-plugin. liuliang...
Read more >
react-refresh-webpack-plugin - Bountysource
So I use your plugin but $RefreshReg$ is not defined error occurred. I follow your Troubleshooting, but none of the solutions work for...
Read more >
Attribute application@ appcomponentfactory value ... - Weebly
Set -X Bash start-bitstransfer path cannot be found because it does not exist ... /usr/bin/python3: No module named pip /usr/bin/ssh-copy-id: ERROR: No ......
Read more >
Continue: Error Cleartext Not Permitted Android Studio - Scribd
for a fatal OpenGL error: libpq-fe.h: No such file or directory private void ... it. serverless-pruning-plugin not found. set -x bash Start-bitstransfer canย ......
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