dzhng / zod-gpt

Get structured, fully typed, and validated JSON outputs from OpenAI and Anthropic models.
MIT License
574 stars 12 forks source link

this environment is missing the following Web Fetch API type: fetch is not defined. You may need to use polyfills #9

Closed sheng-di closed 6 months ago

sheng-di commented 7 months ago
(base) ➜  zod-gpt-test node index.js
~Documents/code/js/github/zod-gpt-test/node_modules/_openai@4.29.2@openai/_shims/web-runtime.js:27
        throw new Error(`this environment is missing the following Web Fetch API type: ${error.message}. ${recommendation}`);
              ^

Error: this environment is missing the following Web Fetch API type: fetch is not defined. You may need to use polyfills
    at getRuntime (~Documents/code/js/github/zod-gpt-test/node_modules/_openai@4.29.2@openai/_shims/web-runtime.js:27:15)
    at Object.<anonymous> (~Documents/code/js/github/zod-gpt-test/node_modules/_openai@4.29.2@openai/shims/web.js:30:55)
    at Module._compile (node:internal/modules/cjs/loader:1196:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
    at Module.load (node:internal/modules/cjs/loader:1074:32)
    at Function.Module._load (node:internal/modules/cjs/loader:909:12)
    at Module.require (node:internal/modules/cjs/loader:1098:19)
    at require (node:internal/modules/cjs/helpers:108:18)
    at Object.<anonymous> (~Documents/code/js/github/zod-gpt-test/node_modules/_llm-api@1.4.1@llm-api/dist/src/models/openai.js:4:1)
    at Module._compile (node:internal/modules/cjs/loader:1196:14)

Does is supoort node? My node version is 16.

dzhng commented 6 months ago

You should really upgrade your node version to 18 or above. Going to close this.