ferdikoomen / openapi-typescript-codegen

NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification
MIT License
2.8k stars 515 forks source link

'fetch is not defined\n' #2124

Closed yzf1116 closed 2 months ago

yzf1116 commented 2 months ago

PS D:\workOther\pnpmProject\packages\vite-project> openapi --input http://10.193.239.107:8082/manage/v2/api-docs --output ./generated --client axios { stack: 'JSONParserError: Error downloading http://10.193.239.107:8082/manage/v2/api-docs \n' + 'fetch is not defined\n' + ' at download (C:\Users\77081\AppData\Roaming\nvm\v16.20.2\node_modules\openapi-typescript-codegen\node_modules\@apidevtools\json-schema-ref-parser\dist\lib\resolvers\http.js:113:15)', code: 'ERESOLVER', name: 'ResolverError', message: 'Error downloading http://10.193.239.107:8082/manage/v2/api-docs \n' + 'fetch is not defined', source: 'http://10.193.239.107:8082/manage/v2/api-docs', path: null, toJSON: [Function: toJSON], footprint: 'null+http://10.193.239.107:8082/manage/v2/api-docs+ERESOLVER+Error downloading http://10.193.239.107:8082/manage/v2/api-docs \n' + 'fetch is not defined', toString: [Function: toString] } What was the problem? please

mrlubos commented 2 months ago

Hey! Can you try updating to Node 18 and use https://github.com/hey-api/openapi-ts?

yzf1116 commented 2 months ago

Hey! Can you try updating to Node 18 and use https://github.com/hey-api/openapi-ts?

thank you vary much, you are right!