trailsjs / sails-swagger

Swagger integration for sails.js
107 stars 47 forks source link

TypeError: Cannot read property 'pkg' of undefined #45

Closed tiham07 closed 6 years ago

tiham07 commented 7 years ago

When trying to run my simple Sails.JS app (with swaggerui included), I'm getting the following error:

$ sails lift

info: Starting app...

debug: hookPath: DummyPath\Software\MyService\node_modules\sails-swagger\dist\api\hooks\swagger
debug: marlinspike (swagger): loading config from DummyPath\Software\MyService\node_modules\sails-swagger\dist\config
debug: marlinspike (swagger): loading Services from DummyPath\Software\MyService\node_modules\sails-swagger\dist\api\services...
warn: marlinspike (swagger): no Services found. skipping
debug: marlinspike (swagger): loading Models...
debug: marlinspike (swagger): loading Controllers...
debug: marlinspike (swagger): loading Policies...
warn: marlinspike (swagger): no Policies found. skipping
DummyPath\Software\MyService\node_modules\sails-swagger\dist\api\hooks\swagger\index.js:49
        hook.doc = _libXfmr2['default'].getSwagger(_this.sails, _this.sails.config.swagger.pkg);
                                                                                          ^

TypeError: Cannot read property 'pkg' of undefined
    at DummyPath\Software\MyService\node_modules\sails-swagger\dist\api\hooks\swagger\index.js:49:91
    at DummyPath\Software\MyService\node_modules\sails\lib\app\private\after.js:91:14
    at DummyPath\Software\MyService\node_modules\sails\node_modules\async\lib\async.js:721:13
    at DummyPath\Software\MyService\node_modules\sails\node_modules\async\lib\async.js:52:16
    at done (DummyPath\Software\MyService\node_modules\sails\node_modules\async\lib\async.js:246:17)
    at DummyPath\Software\MyService\node_modules\sails\node_modules\async\lib\async.js:44:16
    at Sails.<anonymous> (DummyPath\Software\MyService\node_modules\sails\node_modules\async\lib\async.js:718:17)
    at Sails.<anonymous> (DummyPath\Software\MyService\node_modules\sails\node_modules\async\lib\async.js:167:37)
    at Object.onceWrapper (events.js:293:19)
    at emitNone (events.js:86:13)
    at Sails.emit (events.js:188:7)
    at Sails.emitter.emit (DummyPath\Software\MyService\node_modules\sails\lib\app\private\after.js:50:11)
    at sailsReady (DummyPath\Software\MyService\node_modules\sails\lib\app\lift.js:53:11)
    at DummyPath\Software\MyService\node_modules\sails\node_modules\async\lib\async.js:721:13
    at DummyPath\Software\MyService\node_modules\sails\node_modules\async\lib\async.js:52:16
    at DummyPath\Software\MyService\node_modules\sails\node_modules\async\lib\async.js:269:32

npm install, npm uninstall sails or npm cache clear doesn't work. I've already tried to reinstall grunt-cli as well and sails-swagger again... Does anyone have a solution here?

tiham07 commented 6 years ago

I still don't know if this is still supported by the developer. Latest release is from September, 13th 2015: https://github.com/trailsjs/sails-swagger/releases Doesn't seem that the developer(s) is/are interested in this project any further... I've tested this now on a current Windows 10, a current Debian (9.2) and Ubuntu (Ubuntu 16.04.3 LTS). The funny thing is that it doesn't work on any system (even clean install with only npm, nodejs and git shell installed additionally).

gggordon commented 6 years ago

@tiham07 Did you create the config/swagger.js file?

tiham07 commented 6 years ago

Hi @gggordon. I guess that's what I missed somehow. Thank you for your help 👍

tiham07 commented 6 years ago

And I had a wrong configuration in my controller section as well but that was easy to figure out.