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

Node Versions #1

Closed
drew-u410 opened this issue Aug 23, 2023 · 2 comments
Closed

Node Versions #1

drew-u410 opened this issue Aug 23, 2023 · 2 comments
Assignees

Comments

@drew-u410
Copy link

It might be helpful to specify the node version requirements in the README or a .node-version or a .tool-versions file.

It seems that v18 LTS does not work but v20 does work.

It looks to be in swagger-ui-react/swagger-ui-bundle.js:

- info Collecting page data ..TypeError: Class extends value undefined is not a constructor or null
    at 94001 (/Users/drew/src-external/swagger-ui-nextjs/node_modules/swagger-ui-react/swagger-ui-bundle.js:2:296152)
    at n (/Users/drew/src-external/swagger-ui-nextjs/node_modules/swagger-ui-react/swagger-ui-bundle.js:2:1321871)
    at /Users/drew/src-external/swagger-ui-nextjs/node_modules/swagger-ui-react/swagger-ui-bundle.js:2:1329936
    at /Users/drew/src-external/swagger-ui-nextjs/node_modules/swagger-ui-react/swagger-ui-bundle.js:2:1445377
    at /Users/drew/src-external/swagger-ui-nextjs/node_modules/swagger-ui-react/swagger-ui-bundle.js:2:1445393
    at /Users/drew/src-external/swagger-ui-nextjs/node_modules/swagger-ui-react/swagger-ui-bundle.js:2:81
    at Object.<anonymous> (/Users/drew/src-external/swagger-ui-nextjs/node_modules/swagger-ui-react/swagger-ui-bundle.js:2:211)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

TypeError: Class extends value undefined is not a constructor or null
    at 94001 (/Users/drew/src-external/swagger-ui-nextjs/node_modules/swagger-ui-react/swagger-ui-bundle.js:2:296152)
    at n (/Users/drew/src-external/swagger-ui-nextjs/node_modules/swagger-ui-react/swagger-ui-bundle.js:2:1321871)
    at /Users/drew/src-external/swagger-ui-nextjs/node_modules/swagger-ui-react/swagger-ui-bundle.js:2:1329936
    at /Users/drew/src-external/swagger-ui-nextjs/node_modules/swagger-ui-react/swagger-ui-bundle.js:2:1445377
    at /Users/drew/src-external/swagger-ui-nextjs/node_modules/swagger-ui-react/swagger-ui-bundle.js:2:1445393
    at /Users/drew/src-external/swagger-ui-nextjs/node_modules/swagger-ui-react/swagger-ui-bundle.js:2:81
    at Object.<anonymous> (/Users/drew/src-external/swagger-ui-nextjs/node_modules/swagger-ui-react/swagger-ui-bundle.js:2:211)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
@char0n
Copy link
Owner

char0n commented Aug 24, 2023

Hi @drew-u410,

Thanks for initial investigation. The issue is comming from swagger-client: https://github.com/swagger-api/swagger-js/blob/master/src/http/index.js#L201

When the bundle is created, it's assumed it's going to be used in Browser environment. But's that's not the case for Next.js. File doesn't exists in Node.js <= 20. But Next.js claims that it polyfills fetch: https://nextjs.org/docs/architecture/supported-browsers#server-side-polyfills. But unfortunately it really only polyfills fetch and not any other associated symbols, like File, Blob, FormData etc...

Node.js =19.2.0 and =18.13.0, introduced the File under buffer package. Node.js =20.0.0 then introduced File as global symbols (among others) which solves this issue for good:
nodejs/node#47153


For me the most sensible way to proceed forward is to make Node.js >= 20 as minimal required version. What do you think?

@char0n char0n self-assigned this Aug 24, 2023
@char0n
Copy link
Owner

char0n commented Aug 24, 2023

Added support for Node.js>=16 in #2 by polyfilling File object in earlier Node.js versions.

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

No branches or pull requests

2 participants