glideapps / quicktype

Generate types and converters from JSON, Schema, and GraphQL
https://app.quicktype.io
Apache License 2.0
11.93k stars 1.05k forks source link

Support node 21 #2428

Closed chenrui333 closed 9 months ago

chenrui333 commented 10 months ago

There is an issue of running quicktype 23.0.76 against node 21

==> /opt/homebrew/Cellar/quicktype/23.0.76/bin/quicktype --lang typescript --src sample.json
/opt/homebrew/Cellar/quicktype/23.0.76/libexec/lib/node_modules/quicktype/node_modules/browser-or-node/lib/index.js:19
var isJsDom = typeof window !== "undefined" && window.name === "nodejs" || typeof navigator !== "undefined" && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
                                                                                                                                    ^

TypeError: Cannot read properties of undefined (reading 'includes')
    at Object.<anonymous> (/opt/homebrew/Cellar/quicktype/23.0.76/libexec/lib/node_modules/quicktype/node_modules/browser-or-node/lib/index.js:19:133)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Module.load (node:internal/modules/cjs/loader:1201:32)
    at Module._load (node:internal/modules/cjs/loader:1017:12)
    at Module.require (node:internal/modules/cjs/loader:1229:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (/opt/homebrew/Cellar/quicktype/23.0.76/libexec/lib/node_modules/quicktype/node_modules/quicktype-core/dist/input/io/NodeIO.js:40:27)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)

Node.js v21.0.0

relates to https://github.com/Homebrew/homebrew-core/pull/151438

Uzlopak commented 10 months ago

In node 21.1.0 navigator has now userAgent. Is your issue now solved?

basilfx commented 10 months ago

Can confirm that upgrading to Node 21.1.0 fixes this for me.

Porkepix commented 9 months ago

Looks fixed now: https://github.com/Homebrew/homebrew-core/pull/153237

chenrui333 commented 9 months ago

Thanks folks, closing this issue now (the issue is resolved per the linked PR) 💯