theoomoregbee / sails-hook-swagger-generator

A tool to help generate Swagger specification documentation based on OAS 3.0 for Sails APIs
MIT License
78 stars 33 forks source link

Not able to run sails lift if I install this module #47

Closed kanlanc closed 4 years ago

kanlanc commented 5 years ago

This is the error I am getting if I try sails lift after installing this mod. Please note that the app lifts normally when the hook is not installed


 info: Starting app...

 info: Initializing project hook... (`api/hooks/custom/`)
 info: Initializing `apianalytics` hook...  (requests to monitored routes will be logged!)
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity ''
No tag for this identity 'undefined.users'
No tag for this identity 'undefined.users'
No tag for this identity 'undefined.users'
No tag for this identity 'undefined.users'
No tag for this identity 'undefined.bookedservices'
No tag for this identity 'undefined.bookedservices'
No tag for this identity 'undefined.bookedservices'
No tag for this identity 'undefined.credits'
No tag for this identity 'undefined.studios'
No tag for this identity 'undefined.studios'
No tag for this identity 'undefined.studios'
No tag for this identity 'undefined.studios'
No tag for this identity 'undefined.studios'
No tag for this identity 'undefined.services'
No tag for this identity 'undefined.timings'
No tag for this identity 'undefined.timings'
No tag for this identity 'undefined.timings'
error: A hook (`custom`) failed to load!
error: 
error: TypeError: _.contains is not a function
    at Hook.initialize (/home/vikranth/Desktop/Happyfitt-Backend/api/hooks/custom/index.js:36:15)
    at Hook.wrapper [as initialize] (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/@sailshq/lodash/lib/index.js:3275:19)
    at /home/vikranth/Desktop/Happyfitt-Backend/node_modules/sails/lib/hooks/index.js:108:30
    at /home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:421:16
    at processQueue (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:1565:20)
    at taskComplete (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:1588:9)
    at /home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:1612:17
    at /home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:906:16
    at Hook.loadModules (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/sails/lib/hooks/index.js:178:14)
    at Hook.wrapper [as loadModules] (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/@sailshq/lodash/lib/index.js:3275:19)
    at modules (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/sails/lib/hooks/index.js:86:25)
    at runTask (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:1621:13)
    at /home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:1559:13
    at processQueue (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:1569:13)
    at Object.auto (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:1555:5)
    at Hook.load (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/sails/lib/hooks/index.js:80:13)
    at Hook.wrapper [as load] (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/@sailshq/lodash/lib/index.js:3275:19)
    at loadHook (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/sails/lib/app/private/loadHooks.js:212:17)
    at /home/vikranth/Desktop/Happyfitt-Backend/node_modules/sails/lib/app/private/loadHooks.js:344:13
    at /home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:3083:16
    at eachOfArrayLike (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:1003:9)
    at eachOf (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:1051:5)
    at Object.eachLimit (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:3145:5)
    at load (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/sails/lib/app/private/loadHooks.js:342:17)
    at /home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:3853:24
    at replenish (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:946:17)
    at iterateeCallback (/home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:931:17)
    at /home/vikranth/Desktop/Happyfitt-Backend/node_modules/async/dist/async.js:906:16

error: Could not load Sails app.
error: 
error: Tips:
error:  • First, take a look at the error message above.
error:  • Make sure you've installed dependencies with `npm install`.
error:  • Check that this app was built for a compatible version of Sails.
error:  • Have a question or need help?  (http://sailsjs.com/support)
theoomoregbee commented 5 years ago

it's related to https://github.com/mgonto/restangular/issues/1298

https://stackoverflow.com/a/34922709/5836034

one of your installed packages is using an older version of lodash v3 and .contains has been removed from version 4 to use just .includes

Find which package is using an older version of lodash, then see if they have a newer release with a fix to use the latest version

kanlanc commented 5 years ago

probably this one "@sailshq/lodash": "^3.10.3",

kanlanc commented 5 years ago

It turns out this particular npm package doesnt intend to update to lodash 4 at all from their README. Should I change the globals to lodash 4, will this solve the problem

kanlanc commented 5 years ago

or is there a way I can tell this package to use lodash 3

marcnicole commented 4 years ago

in fact sails internally uses lodash 3, but this doesn't prevent you to use v4 (which is needed for sails-hook-swagger-generator)

the only thing is that the code of the ./api/hooks/custom/index.js (that has been generated by sails new) is using .contains instead of .includes. just correct that line replacing ```.containsby_.includes```

image

it should then be ok

cf https://sailsjs.com/documentation/reference/configuration/sails-config-globals