npm 找不到命令
1. 输入 `get-ExecutionPolicy` 显示 Restricted (受限的)
2. 再输入 `Set-ExecutionPolicy -Scope CurrentUser`
输入 RemoteSigned 给用户赋予权限即可
请求时返回JSON报错
-
上方命令向openapi 请求生成时返回 json报错
{ stack: 'JSONParserError: Error downloading http://localhost:8121/api/v2/api-docs \n' + 'fetch is not defined\n' + ' at download (E:\\workspace\\CxCSOJ\\cxcsoj-frontend\\node_modules\\@apidevtools\\json-schema-ref-parser\\dist\\lib\\resolvers\\http.js:1 13:15)', code: 'ERESOLVER', name: 'ResolverError', message: 'Error downloading http://localhost:8121/api/v2/api-docs \n' + 'fetch is not defined', source: 'http://localhost:8121/api/v2/api-docs', path: null, toJSON: [Function: toJSON], footprint: 'null+http://localhost:8121/api/v2/api-docs+ERESOLVER+Error downloading http://localhost:8121/api/v2/api-docs \n' + 'fetch is not defined', toString: [Function: toString] }
-
解决方案: OpenAPI 生成的客户端有冲突的请求
对
OpenAPI Typescript Codegen
版本进行降级到0.25.0npm i openapi-typescript-codegen@0.25.0
使用以下命令生成
npx openapi-typescript-codegen --input http://localhost:8121/api/v2/api-docs --output ./generated --client axios