ReferenceError: React is not defined
Describe the bug
The following error appears since today: ReferenceError: React is not defined.
We install the latest version globally and use it in our GitHub Action for the following command: npx redocly bundle ${dest_folder}/swagger.yaml -o ${dest_folder}/swagger-prepared.json
To Reproduce
npm install -g @redocly/cli@latestredocly --help
Expected behavior
No error, exit code 0.
Logs
ReferenceError: React is not defined
at Object.<anonymous> (/usr/local/lib/node_modules/@redocly/cli/node_modules/styled-components/dist/styled-components.cjs.js:1:860)
at Module._compile (node:internal/modules/cjs/loader:1521:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)
at Module.load (node:internal/modules/cjs/loader:1266:32)
at Module._load (node:internal/modules/cjs/loader:1091:12)
at Module.require (node:internal/modules/cjs/loader:1289:19)
at require (node:internal/modules/helpers:182:18)
at /usr/local/lib/node_modules/@redocly/cli/node_modules/redoc/bundles/redoc.lib.js:2:109941
at /usr/local/lib/node_modules/@redocly/cli/node_modules/redoc/bundles/redoc.lib.js:1831:3804
at /usr/local/lib/node_modules/@redocly/cli/node_modules/redoc/bundles/redoc.lib.js:1831:3809
Node.js v20.20.0
OpenAPI description
# See https://redocly.com/docs/cli/configuration/
extends:
- recommended
rules:
# Currently we don't have a license for our APIs
info-license: "off"
theme:
openapi:
generateCodeSamples:
languages:
- lang: curl
- lang: Node.js
- lang: Python
Redocly version(s)
2.18.2
Node.js version(s)
v20.20.0
OS, environment
Linux, Max, GitHub ubuntu-latest
Additional context
It worked the last 3 years until today (can't say if it worked the last 2 days, but definitely before).
same exact issue here. Was working fine up until last night and started breaking with the same error today.
There's some issue on a dependency's side (most likely with styled-components). We're already investigating it.
Same issue here!
same here
https://github.com/styled-components/styled-components/issues/5667
@tatomyr thanks! curious though, this has happened a couple times in recent months. Shouldn't redocly-cli pin its deps to avoid surprises like this?
same here
@mscrivo yeah, this is one of the options.
Hey,
you can add the override for styled-components to avoid the error until this is figured out.
e.g.
"devDependencies": {
"@redocly/cli": "^2.0.0"
},
"overrides": {
"styled-components": "6.1.19"
},
Hey,
you can add the override for styled-components to avoid the error until this is figured out.
e.g.
"devDependencies": { "@redocly/cli": "^2.0.0" }, "overrides": { "styled-components": "6.1.19" },
Doesn't work when running it in the command line though
The fix is underway, folks. Tests are running...
We’re seeing the same issue across all our CI/CD pipelines. Thank you for addressing this so quickly.
Released the fix to NPM.
I still got this error:
node:internal/modules/run_main:123
triggerUncaughtException(
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/build/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/react-dom/server' imported from /build/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@redocly/cli/lib/commands/build-docs/utils.js
Did you mean to import "react-dom/server.js"?
at finalizeResolution (node:internal/modules/esm/resolve:274:11)
at moduleResolve (node:internal/modules/esm/resolve:859:10)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at #cachedDefaultResolve (node:internal/modules/esm/loader:731:20)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:310:38)
at ModuleJob._link (node:internal/modules/esm/module_job:182:49) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///build/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/react-dom/server'
@tatomyr We see same problem on latest v1 (1.34.6). Is there any chance to also push a v1 fix? It broke on an automation on our side and we can't easily upgrade to v2. At least not that quickly.
Working on the fix for V1.
Thanks for fixing this too fast!!!
fixed for v1 too, please let as know if you still have an issue
@chiefbrain could you please provide a little bit more details about your issue ?
@vadyvas Can you also apply to 1.19.0? I'm having the same issue