fmvilas / swagger-node-codegen

An OpenAPI 3.x/Swagger 2 code generator for Node.js
Apache License 2.0
200 stars 55 forks source link

Issue on generation #20

Closed Crysalist closed 6 years ago

Crysalist commented 6 years ago

I used the default swagger spec on http://editor.swagger.io/ When I run it snc swagspec.yaml -o ./my-api or snc swagspec.yaml

But I get error /usr/local/lib/node_modules/swagger-node-codegen/lib/codegen.js:138 walker.on('file', async (root, stats, next) => { ^

SyntaxError: Unexpected token ( at createScript (vm.js:56:10) at Object.runInThisContext (vm.js:97:10) at Module._compile (module.js:542:28) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object. (/usr/local/lib/node_modules/swagger-node-codegen/cli.js:6:17)

richardklose commented 6 years ago

Which Node.JS version do you use?

This is Node complaining about a ( in this line and this may be the one after async. async support was introduced with V8 5.5 which is available since Node.JS 7.6. So if you are using an older version this won't work.

fmvilas commented 6 years ago

What's your Node.js version and OS?

Crysalist commented 6 years ago

Got it sorted ... issue was the error is not descriptive in linux. On Mac I saw what the issue where and fixed it. (There was a random reference that does not exist in the swagger file)