I used this code. I filled out everything, ID, Secret, callback url, and local database.
I set the urls on my facebook app to "http://localhost:3000/" and for the url of the website I tried both "http://localhost:3000/" and "http://localhost:3000/auth/facebook/callback"
Also I changed the port on the app from 8080 to 3000 to match it.
Whenever I clicked the login, the server would crash, telling me there was an uncaught error somewhere in a node module of mongoose and that it couldn't "read property 0 of undefined", so I figured that would happen if there was no permission to access the email scope (since it does newUser.facebook.email = profile.emails[0].value;), so I tried to comment out that line.
After commenting out that line, the server wouldn't crash anymore when doing the login, and when I was redirected to the profile page, I got the token, ID, and displayName.
So, the login works if I don't request the email, but when I add that line of code to request the email, it crashes.
I'm requesting the "email" scope like this:
app.get("/auth/facebook", passport.authenticate("facebook", {scope: ["email"]}));
I searched previous questions, but I couldn't find what I was looking for. What can I do?