sails101 / using-passport

How do I use Passport with my Sails app?
67 stars 14 forks source link

Error on lifting sails #7

Open skulltech opened 7 years ago

skulltech commented 7 years ago

Running sails lift gives the following error.

sumit@sumit-HP-Pavilion-Notebook:~/Coding/using-passport$ sails lift

info: Starting app...

module.js:471
    throw err;
    ^

Error: Cannot find module 'express/node_modules/cookie'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/sumit/Coding/using-passport/node_modules/sails/lib/hooks/session/index.js:9:12)
    at Module._compile (module.js:570:32)
    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 /home/sumit/Coding/using-passport/node_modules/sails/lib/app/configuration/index.js:54:28
    at Function.reduce (/home/sumit/Coding/using-passport/node_modules/sails/node_modules/lodash/dist/lodash.js:3735:25)
    at Configuration.defaultConfig (/home/sumit/Coding/using-passport/node_modules/sails/lib/app/configuration/index.js:53:18)
    at Configuration.bound [as defaults] (/home/sumit/Coding/using-passport/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
sumit@sumit-HP-Pavilion-Notebook:~/Coding/using-passport$ 
AlbanWende commented 7 years ago

there are severals errors like this issue. That is due to packages non listed in the package.json. run "npm install --save 'name_of_the_package_in_the_error'".

designnotdrum commented 7 years ago

Even installing the proper npm modules will not solve these issues, unfortunately.

Because npm flattened out their dependency module loading post v3.0, this tutorial is way out-of date. There are several places you need to touch in order to make sure you can get everything working appropriately.

Please note that the below solution only works if you are using Sails ~0.10.x, per the included package.json

Firstly, install the 'connect' module, as it is omitted from the package.json file included with this repo. npm install connect --save

Then, you will need to touch the following files and adjust the require references by removing the nested node path.

_/using-passport/nodemodules/sails/lib/hooks/session/index.js --> Has 2 references to connect, and one to cookie

_/using-passport/nodemodules/sails/lib/hooks/sockets/lib/loadSocketIO.js --> Has 2 references to redis

_/using-passport/nodemodules/sails/lib/hooks/sockets/lib/authorization.js --> Has 2 references to connect, and one to cookie

and finally, adjusting the grunt-cli references in _/using-passport/nodemodules/sails/lib/hooks/grunt/index.js path.join(pathToSails,'../grunt-cli/bin/grunt'),