Closed denimamab closed 9 months ago
I'm getting the same issue I think:
~/Programming/js/rpg-app $ npx react-query-swagger /tanstack /input:http://local
host:8000/openapi.json /output:src/api/client.ts /template:Axios
node:child_process:962
throw err;
^
Error: Command failed: "/Users/isaac/Programming/js/rpg-app/node_modules/nswag-p
ortable/bin/nswag-portable.mac.arm" openapi2tsclient /templateDirectory:/Users/i
saac/Programming/js/rpg-app/node_modules/react-query-swagger/templates /typeScri
ptVersion:4 /tanstack /input:http://localhost:8000/openapi.json /output:src/api/
client.ts /template:Axios
at checkExecSyncError (node:child_process:887:11)
at Object.execSync (node:child_process:959:15)
at Object.<anonymous> (/Users/isaac/Programming/js/rpg-app/node_modules/nswa
g-portable/nswag-portable.js:19:14)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_ma
in:83:12)
at node:internal/main/run_main_module:23:47 {
status: null,
signal: 'SIGKILL',
output: [ null, null, null ],
pid: 24911,
stdout: null,
stderr: null
}
Node.js v20.5.1
/Users/isaac/Programming/js/rpg-app/node_modules/react-query-swagger/cli.js:173
throw new Error(e?.output?.toString());
^
Error: ,NSwag NPM CLI
,node:child_process:962
throw err;
^
Error: Command failed: "/Users/isaac/Programming/js/rpg-app/node_modules/nswag-p
ortable/bin/nswag-portable.mac.arm" openapi2tsclient /templateDirectory:/Users/i
saac/Programming/js/rpg-app/node_modules/react-query-swagger/templates /typeScri
ptVersion:4 /tanstack /input:http://localhost:8000/openapi.json /output:src/api/
client.ts /template:Axios
at checkExecSyncError (node:child_process:887:11)
at Object.execSync (node:child_process:959:15)
at Object.<anonymous> (/Users/isaac/Programming/js/rpg-app/node_modules/nswa
g-portable/nswag-portable.js:19:14)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_ma
in:83:12)
at node:internal/main/run_main_module:23:47 {
status: null,
signal: 'SIGKILL',
output: [ null, null, null ],
pid: 24911,
stdout: null,
stderr: null
}
Node.js v20.5.1
at Object.<anonymous> (/Users/isaac/Programming/js/rpg-app/node_modules/reac
t-query-swagger/cli.js:173:9)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_ma
in:83:12)
at node:internal/main/run_main_module:23:47
Node.js v20.5.1
I'm gonna try fixing it coming week. Don't have M2 at hand, unfortunately
I did some testing for each version back to 15.6.1 I get the same issue for 15.7, 15.8, 15.9 and 15.10 and I get the following for 15.6 (note had to drop ts to 4.9.x for this one):
$ npx react-query-swagger /tanstack /input:http://local
host:8000/openapi.json /output:src/api/client.ts /template:Axios
node:child_process:962
throw err;
^
Error: Command failed: "/Users/isaac/Programming/js/rpg-app/node_modules/nswag-p
ortable/bin/nswag-portable.mac" openapi2tsclient /templateDirectory:/Users/isaac
/Programming/js/rpg-app/node_modules/react-query-swagger/templates /typeScriptVe
rsion:4 /tanstack /input:http://localhost:8000/openapi.json /output:src/api/clie
nt.ts /template:Axios
at checkExecSyncError (node:child_process:887:11)
at Object.execSync (node:child_process:959:15)
at Object.<anonymous> (/Users/isaac/Programming/js/rpg-app/node_modules/nswa
g-portable/nswag-portable.js:17:14)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_ma
in:83:12)
at node:internal/main/run_main_module:23:47 {
status: 255,
signal: null,
output: [ null, null, null ],
pid: 26836,
stdout: null,
stderr: null
}
Node.js v20.5.1
/Users/isaac/Programming/js/rpg-app/node_modules/react-query-swagger/cli.js:169
throw new Error(e?.output?.toString());
^
Error: ,NSwag NPM CLI
NSwag command line tool for .NET Core, toolchain v13.18.2.0 (NJsonSchema v11.0.0
.0 (Newtonsoft.Json v13.0.0.0))
Visit http://NSwag.org for more information.
NSwag bin directory could not be determined: CodeBase is not supported on assemb
lies loaded from a single-file bundle.
System.InvalidOperationException: Error while rendering Liquid template TypeScri
pt/Class:
Object reference not set to an instance of an object.
---> System.NullReferenceException: Object reference not set to an instance of
an object.
at NJsonSchema.CodeGeneration.TypeScript.TypeScriptTypeResolver.GetNullableIt
emType(JsonSchema schema, String itemType)
at NJsonSchema.CodeGeneration.TypeScript.TypeScriptTypeResolver.<>c__DisplayC
lass16_0.<ResolveArrayOrTuple>b__1(JsonSchema s)
at System.Linq.Enumerable.SelectIListIterator`2.ToArray()
at NJsonSchema.CodeGeneration.TypeScript.TypeScriptTypeResolver.ResolveArrayO
rTuple(JsonSchema schema, String typeNameHint, Boolean addInterfacePrefix)
at NJsonSchema.CodeGeneration.TypeScript.TypeScriptTypeResolver.Resolve(JsonS
chema schema, String typeNameHint, Boolean addInterfacePrefix)
at NJsonSchema.CodeGeneration.TypeScript.TypeScriptTypeResolver.Resolve(JsonS
chema schema, Boolean isNullable, String typeNameHint)
at NJsonSchema.CodeGeneration.TypeScript.TypeScriptTypeResolver.ResolveArrayO
rTuple(JsonSchema schema, String typeNameHint, Boolean addInterfacePrefix)
at NJsonSchema.CodeGeneration.TypeScript.TypeScriptTypeResolver.Resolve(JsonS
chema schema, String typeNameHint, Boolean addInterfacePrefix)
at NJsonSchema.CodeGeneration.TypeScript.TypeScriptTypeResolver.Resolve(JsonS
chema schema, Boolean isNullable, String typeNameHint)
at NJsonSchema.CodeGeneration.TypeScript.Models.PropertyModel.get_Type()
at Fluid.Accessors.PropertyInfoAccessor.Invoker`2.Invoke(Object target)
at Fluid.Accessors.PropertyInfoAccessor.Get(Object obj, String name, Template
Context ctx)
at Fluid.Values.ObjectValueBase.GetValueAsync(String name, TemplateContext co
ntext)
at Fluid.Ast.IdentifierSegment.ResolveAsync(FluidValue value, TemplateContext
context)
at Fluid.Ast.MemberExpression.EvaluateAsync(TemplateContext context)
at Fluid.Ast.OutputStatement.WriteToAsync(TextWriter writer, TextEncoder enco
der, TemplateContext context)
at Fluid.Ast.ForStatement.WriteToAsync(TextWriter writer, TextEncoder encoder
, TemplateContext context)
at Fluid.Parser.FluidTemplate.Awaited(ValueTask`1 task, TextWriter writer, Te
xtEncoder encoder, TemplateContext context, IReadOnlyList`1 statements, Int32 st
artIndex)
at Fluid.FluidTemplateExtensions.RenderAsync(IFluidTemplate template, Templat
eContext context, TextEncoder encoder)
at NJsonSchema.CodeGeneration.DefaultTemplateFactory.LiquidTemplate.Render()
--- End of inner exception stack trace ---
at NJsonSchema.CodeGeneration.DefaultTemplateFactory.LiquidTemplate.Render()
at NJsonSchema.CodeGeneration.CodeArtifact..ctor(String typeName, String base
TypeName, CodeArtifactType type, CodeArtifactLanguage language, CodeArtifactCate
gory category, ITemplate template)
at NJsonSchema.CodeGeneration.TypeScript.TypeScriptGenerator.GenerateType(Jso
nSchema schema, String typeNameHint)
at NJsonSchema.CodeGeneration.GeneratorBase.GenerateTypes()
at NJsonSchema.CodeGeneration.TypeScript.TypeScriptGenerator.<>n__0()
at NJsonSchema.CodeGeneration.TypeScript.TypeScriptGenerator.GenerateTypes(Ty
peScriptExtensionCode extensionCode)+MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at NJsonSchema.CodeGeneration.CodeArtifactExtensions.OrderByBaseDependency(IE
numerable`1 results)
at NSwag.CodeGeneration.TypeScript.Models.TypeScriptFileTemplateModel..ctor(I
Enumerable`1 clientTypes, IEnumerable`1 dtoTypes, OpenApiDocument document, Type
ScriptExtensionCode extensionCode, TypeScriptClientGeneratorSettings settings, T
ypeScriptTypeResolver resolver)
at NSwag.CodeGeneration.TypeScript.TypeScriptClientGenerator.GenerateFile(IEn
umerable`1 clientTypes, IEnumerable`1 dtoTypes, ClientGeneratorOutputType output
Type)
at NSwag.CodeGeneration.ClientGeneratorBase`3.GenerateFile(ClientGeneratorOut
putType outputType)
at NSwag.CodeGeneration.ClientGeneratorBase`3.GenerateFile()
at NSwag.Commands.CodeGeneration.SwaggerToTypeScriptClientCommand.RunAsync()
at NSwag.Commands.CodeGeneration.SwaggerToTypeScriptClientCommand.RunAsync(Co
mmandLineProcessor processor, IConsoleHost host)
at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object inp
ut)
at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input)
at NSwag.Commands.NSwagCommandProcessor.ProcessAsync(String[] args),node:chil
d_process:962
throw err;
^
Error: Command failed: "/Users/isaac/Programming/js/rpg-app/node_modules/nswag-p
ortable/bin/nswag-portable.mac" openapi2tsclient /templateDirectory:/Users/isaac
/Programming/js/rpg-app/node_modules/react-query-swagger/templates /typeScriptVe
rsion:4 /tanstack /input:http://localhost:8000/openapi.json /output:src/api/clie
nt.ts /template:Axios
at checkExecSyncError (node:child_process:887:11)
at Object.execSync (node:child_process:959:15)
at Object.<anonymous> (/Users/isaac/Programming/js/rpg-app/node_modules/nswa
g-portable/nswag-portable.js:17:14)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_ma
in:83:12)
at node:internal/main/run_main_module:23:47 {
status: 255,
signal: null,
output: [ null, null, null ],
pid: 26836,
stdout: null,
stderr: null
}
Node.js v20.5.1
at Object.<anonymous> (/Users/isaac/Programming/js/rpg-app/node_modules/reac
t-query-swagger/cli.js:169:9)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_ma
in:83:12)
at node:internal/main/run_main_module:23:47
Node.js v20.5.1
Running with v15.10.3 and ts v4.9.x gives the same errors as 15.7-15.10
@Shaddix anything we can help with ?
Just to double-check, could you please try running the following commands:
npx nswag-portable openapi2tsclient /typeScriptVersion:"4" /tanstack /input:https://petstore.swagger.io/v2/swagger.json /output:src/api/axios-client-minimal.ts /template:Axios /serviceHost:. /minimal
and
npx nswag-portable help openapi2tsclient
to check if they work.
I'm trying them out on Bitrise M1 machine and they work, it seems to me that it shouldn't be an issue on M2 as well..
Here is the commands results
➜ react-query git:(main) ✗ npx nswag-portable openapi2tsclient /typeScriptVersion:"4" /tanstack /input:https://petstore.swagger.io/v2/swagger.json /output:src/api/axios-client-minimal.ts /template:Axios /serviceHost:. /minimal
NSwag NPM CLI
node:child_process:965
throw err;
^
Error: Command failed: "/Users/.../Documents/lab/nest-js-open-api-generator/todo-api-client/node_modules/nswag-portable/bin/nswag-portable.mac.arm" openapi2tsclient /typeScriptVersion:4 /tanstack /input:https://petstore.swagger.io/v2/swagger.json /output:src/api/axios-client-minimal.ts /template:Axios /serviceHost:. /minimal
at checkExecSyncError (node:child_process:890:11)
at Object.execSync (node:child_process:962:15)
at Object.<anonymous> (/Users/.../Documents/lab/nest-js-open-api-generator/todo-api-client/node_modules/nswag-portable/nswag-portable.js:19:14)
at Module._compile (node:internal/modules/cjs/loader:1241:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47 {
status: null,
signal: 'SIGKILL',
output: [ null, null, null ],
pid: 10132,
stdout: null,
stderr: null
}
Node.js v20.9.0
➜ react-query git:(main) ✗ npx nswag-portable help openapi2tsclient
NSwag NPM CLI
node:child_process:965
throw err;
^
Error: Command failed: "/Users/.../Documents/lab/nest-js-open-api-generator/todo-api-client/node_modules/nswag-portable/bin/nswag-portable.mac.arm" help openapi2tsclient
at checkExecSyncError (node:child_process:890:11)
at Object.execSync (node:child_process:962:15)
at Object.<anonymous> (/Users/.../Documents/lab/nest-js-open-api-generator/todo-api-client/node_modules/nswag-portable/nswag-portable.js:19:14)
at Module._compile (node:internal/modules/cjs/loader:1241:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47 {
status: null,
signal: 'SIGKILL',
output: [ null, null, null ],
pid: 10171,
stdout: null,
stderr: null
}
Node.js v20.9.0
➜ react-query git:(main) ✗
I think it's mainly related to .NET compatibility with M2 ...
I think it's mainly related to .NET compatibility with M2 ...
Yep. But it should be compatible. I've found an M1, will investigate today
Thanks for looking into it, @Shaddix -- i just found this library today, and am super excited to try it out! Also on an M2 here...
So, here's my temporary dirty fix for anyone interested:
Open a rosetta terminal (I've added a ready-to-go one to my VSCode dropdown like so):
You can also do it like this
Create a new Node installation using nvm
in Rosetta mode
Alias it as rosetta
nvm alias rosetta x.x.x <- Your version of choice
Create a reinstall
or reset
script in package.json:
"reinstall": "rm -rf node_modules && npm install"
Everytime you want to sync you do the following (in a rosetta terminal):
react-query-swagger
commandAn example below:
> nvm ls
v18.18.2
-> v20.9.0
system
arm -> v20.9.0
default -> 20.9.0 (-> v20.9.0)
rosetta -> v18.18.2
> nvm use rosetta
Now using node v18.18.2 (npm v9.8.1)
> arch
i386
> node -p "process.arch"
x64
> npm run reinstall
> npx tsx ./scripts/generate-api.ts
🏗️ Generating query hooks for <secret>...
🏗️ Generating query hooks for <secret>...
✅ Generated query hooks for <secret>
🪄 Fixing <secret>...
✅ Fixed <secret>
✅ Generated query hooks for <secret>
🪄 Fixing <secret>...
✅ Fixed <secret>
📝 Formatting code...
✅ Formatted
Open regular terminal
Run your reinstall-script
npm run reinstall
Done! ✅
@VidunderGunder oh thanks for the efforts, I'll try that on my return. But still I don't think it's the best developer experience you get doing all this stuff. I will try some alternatives proposed on the TanStack community section: Tanstack
@denimamab Yeah, it's a hassle. Would love to have this working natively again.
could you please try the latest version, it worked on my M1, hope it fixes M2 as well
@Shaddix Same error* here using the latest 15.10.4 on a Apple M1 Pro, 32 GB, Sonoma 14.1.1 (23B81). Node at 20.9.0.
Reinstalling after deleting node_modules and lock file didn't help either.
*Update: On closer inspection, it may be something else going wrong with NSwag in my case. Troubleshooting it now, but you can consider this issue solved.
@Shaddix on my M2 seems to be working, thank you for the fix!
@Shaddix It's working again 🥳 We were just facing some weird VPN issues that threw a similar error after the update. Sorry about that 😅
Hey ! Im facing the same issue on Mac M2: Version used: 15.10.3 Node version: v20.9.0
Output:
Originally posted by @denimamab in https://github.com/Shaddix/react-query-swagger/issues/21#issuecomment-1805499771