Open Rohaan-I opened 9 years ago
I have just installed and am also getting this error.
+1
+1
+1
\node_modules\sails-auth\api\hooks\sails-auth.js:4
sails.services.passport.loadStrategies();
^
TypeError: Cannot read property 'loadStrategies' of undefined
at Hook.initialize (\node_modules\sails-auth\api\hooks\sails-auth.js:4:30)
at Hook.bound [as initialize] (\node_modules\lodash\dist\lodash.js:729:21)
at \node_modules\sails\lib\hooks\index.js:75:14
at \node_modules\sails\node_modules\async\lib\async.js:451:17
at \node_modules\sails\node_modules\async\lib\async.js:441:17
at _each (\node_modules\sails\node_modules\async\lib\async.js:46:13)
at Immediate.taskComplete (\node_modules\sails\node_modules\async\lib\async.js:440:13)
at processImmediate [as _immediateCallback] (timers.js:374:17)
+1 happening with sails latest stable
i have the same issue
What version of sails are you guys running?
@tjwebb I'm running v0.11.2
My Error Message:
/home/xxx/xxx/node_modules/sails-auth/api/hooks/sails-auth.js:4
sails.services.passport.loadStrategies();
^
TypeError: Cannot read property 'loadStrategies' of undefined
at Hook.initialize (/home/xxx/xxx/node_modules/sails-auth/api/hooks/sails-auth.js:4:30)
at Hook.bound [as initialize] (/usr/local/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at /usr/local/lib/node_modules/sails/lib/hooks/index.js:75:14
at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:451:17
at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:441:17
at _each (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:46:13)
at Immediate.taskComplete (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:440:13)
at processImmediate [as _immediateCallback] (timers.js:367:17)
Same version as manuel140 on Windows 10 64-bit @tjwebb.
@tjwebb I'm in the same boat; I'm running the same version as manuel140 and GiantCrocodile on Ubuntu.
And this is happening on sails-auth 1.3.1?
{ Desktop } » mkdir test /cygdrive/c/Users/2c/Desktop
{ Desktop } » cd test /cygdrive/c/Users/2c/Desktop
{ test } » sails new /cygdrive/c/Users/2c/Desktop/test
info: Created a new Sails app `test`!
{ test } » sails lift /cygdrive/c/Users/2c/Desktop/test
info: Starting app...
info:
info: .-..-.
info:
info: Sails <| .-..-.
info: v0.11.0 |\
info: /|.\
info: / || \
info: ,' |' \
info: .-'.-==|/_--'
info: `--'-------'
info: __---___--___---___--___---___--___
info: ____---___--___---___--___---___--___-__
info:
info: Server lifted in `C:\Users\2c\Desktop\test`
info: To see your app, visit http://localhost:1337
info: To shut down Sails, press <CTRL> + C at any time.
debug: --------------------------------------------------------
debug: :: Tue Sep 29 2015 22:22:26 GMT-0700 (Pacific Daylight Time)
debug: Environment : development
debug: Port : 1337
debug: --------------------------------------------------------
{ test } » npm i sails-auth --save /cygdrive/c/Users/2c/Desktop/test 130
sails-auth@1.3.1 node_modules\sails-auth
├── passport-twitter@1.0.3 (xtraverse@0.1.0, passport-oauth1@1.0.1)
├── passport-facebook@1.0.3 (passport-oauth2@1.1.2)
└── passport-google-oauth@0.2.0 (pkginfo@0.3.0, passport-oauth@1.0.0)
{ test } » sails lift /cygdrive/c/Users/2c/Desktop/test
info: Starting app...
C:\Users\2c\Desktop\test\node_modules\sails-auth\api\hooks\sails-auth.js:4
sails.services.passport.loadStrategies();
^
TypeError: Cannot read property 'loadStrategies' of undefined
at Hook.initialize (C:\Users\2c\Desktop\test\node_modules\sails-auth\api\hooks\sails-auth.js:4:30)
at Hook.bound [as initialize] (C:\Users\2c\AppData\Roaming\npm\node_modules\sails\node_modules\lodash\dist\lodash.js:729:21)
at C:\Users\2c\AppData\Roaming\npm\node_modules\sails\lib\hooks\index.js:75:14
at C:\Users\2c\AppData\Roaming\npm\node_modules\sails\node_modules\async\lib\async.js:451:17
at C:\Users\2c\AppData\Roaming\npm\node_modules\sails\node_modules\async\lib\async.js:441:17
at _each (C:\Users\2c\AppData\Roaming\npm\node_modules\sails\node_modules\async\lib\async.js:46:13)
at Immediate.taskComplete (C:\Users\2c\AppData\Roaming\npm\node_modules\sails\node_modules\async\lib\async.js:440:13)
at processImmediate [as _immediateCallback] (timers.js:367:17)
{ test } » /cygdrive/c/Users/2c/Desktop/test 1
edit: dies on sails 11.2 as well
:+1: I run into same problem on Sails version: 0.11.2, sails-auth 1.3.1
+1
+1
I'm running into the same issue. Details of my context:
To reproduce the issue:
info: Starting app...
/home/.../webapp/node_modules/sails-auth/api/hooks/sails-auth.js:4
sails.services.passport.loadStrategies();
^
TypeError: Cannot read property 'loadStrategies' of undefined
at Hook.initialize (/home/.../webapp/node_modules/sails-auth/api/hooks/sails-auth.js:4:30)
at Hook.bound [as initialize] (/home/.../node-v0.12.7-linux-x64/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at /home/.../node-v0.12.7-linux-x64/lib/node_modules/sails/lib/hooks/index.js:75:14
at /home/.../node-v0.12.7-linux-x64/lib/node_modules/sails/node_modules/async/lib/async.js:451:17
at /home/.../node-v0.12.7-linux-x64/lib/node_modules/sails/node_modules/async/lib/async.js:441:17
at _each (/home/.../node-v0.12.7-linux-x64/lib/node_modules/sails/node_modules/async/lib/async.js:46:13)
at Immediate.taskComplete (/home/.../node-v0.12.7-linux-x64/lib/node_modules/sails/node_modules/async/lib/async.js:440:13)
at processImmediate [as _immediateCallback] (timers.js:367:17)
@tjwebb
As you might know, the issue is due to the fact that sails services
are loaded after sails hooks
in versions 0.11.0
and 0.11.2
that I have tested.
It is more logical that all components of a hook
are loaded before the hook
itself (which was assumed by the developer of the hook
).
+1
Does anyone have a workaround?
I have the same setup as @ouadi
It looks like it is a 'hard to solve malfunction': the hook expects that its services have been loaded before it gets loaded itself, which is not the case. In addition, both Sails.js and sails-auth hook are far away from there latest release 1.11.2 and 1.3.1 respectively. So, I expect that the solution from sails.js team will take time.
Till then, I'm using now passport.js directly. People interested in this alternative can find its description here.
@ouadi yup i also considering to use passports directly, but we may need to glue diff libraries by ourselves and also need to consider when to switch back to sails.
I hope that our friends in sails team get quickly a time slot to solve this issue as it is a show stopper
for two great extensions: sails-auth and sails-permission. They are doing a great job so far and I'm all hope that they will keep up on the same level of excellence.
I was just trying to start a fresh project and encountered this (My luck, the day I start...)
While this might not be an acceptable production work around, it got me developing: by uninstalling sails v0.11.2, and reinstalling sails@balderdashy/sails (which installs v12 rc), then in my project specifically installing sails-auth@2.1.1
Thanks for the workaround @synaxin
+1
@synaxin :+1:
We will try to address this soon. Thank you all for your support.
+1
Not to throw this hardworking team under the bus, do appriciate their work, but I tried Waterlock and it works like a charm!
I experienced the same problem. After a bit of googling I found this solution. After editing my package.json
and setting the version of sails-auth
to 1.2.3 it fixes my problem.
Another workaround you can try:
Create passport.js file under [project]\api\services and put this code inside: module.exports = require('sails-auth/api/services/passport');
thanks @muradaliyev i tried them all and that did it! :)
Ps I had to do it in conjunction with repeating:
npm install sails-permissions sails-auth@^2 --save
In conjunction with:
@dioptre, it looks like we need to repeat the same trick with sails-auth/api/services/authservice.js, If it is not already created with generator script.
It is responsible for the next=url parameter in login request (if you want to redirect browser after successful login)
+1 for the issue and +1 for @muradaliyev's workaround! :)
specify sails-auth version to 2.1.1 in package.json can resolve this problem.
thanks @YoleYu that worked for me
I had the same problems in one of my sails app repositories. I fixed it by installing a previous version of sails-auth.
npm install sails-auth@1.2.3
This fixed it for me. I also updated dependency reference for my package.json from
"sails-auth": "^1.0.10",
to
"sails-auth": "1.2.3",
After this I was able to lift with no problems. I created an issue report here: https://github.com/balderdashy/sails/issues/3385
Hope this helps.
I was building an app using sailsjs and after week ago it was working fine but right now I'm getting this error. I did'nt change anything. The stacktrace is given below:-
/home/redbuffer/my_stuff/apps/AfterEidApp1/node_modules/sails-auth/api/hooks/sails-auth.js:4 sails.services.passport.loadStrategies(); ^ TypeError: Cannot read property 'loadStrategies' of undefined at Hook.initialize (/home/redbuffer/my_stuff/apps/AfterEidApp1/node_modules/sails-auth/api/hooks/sails-auth.js:4:30) at Hook.bound as initialize at /home/redbuffer/my_stuff/apps/AfterEidApp1/node_modules/sails/lib/hooks/index.js:78:14 at /home/redbuffer/my_stuff/apps/AfterEidApp1/node_modules/sails/node_modules/async/lib/async.js:451:17 at /home/redbuffer/my_stuff/apps/AfterEidApp1/node_modules/sails/node_modules/async/lib/async.js:441:17 at _each (/home/redbuffer/my_stuff/apps/AfterEidApp1/node_modules/sails/node_modules/async/lib/async.js:46:13) at Immediate.taskComplete (/home/redbuffer/my_stuff/apps/AfterEidApp1/node_modules/sails/node_modules/async/lib/async.js:440:13) at processImmediate as _immediateCallback