Node API works locally on Mac but throws errors on Ubuntu VPS

April 30, 2015 429 views
API Deployment MEAN MongoDB Node.js DigitalOcean Linux Basics Nginx Ubuntu

I have a MEAN stack application that works just fine locally on a Mac, but does not work properly once deployed to VPS. I've struggled with debugging it (first I thought it was an issue with Nginx, but that turned out to be a red herring, and then PM2 was masking the Node errors). I believe I managed to trace the errors into my Node API now. It fails MongoDB lookups.

The confusing thing is that I have another MEAN stack application that uses the same authentication API and works fine, whereas it fails on the new app. Both are deployed on the same droplet, so all settings are primarily the same. The working app is the boilerplate that I built for the non-working app.

Here is the working API boilerplate:

And the non-working API:

I documented some of the issues here:

I believe the primary issue is that when the user logs into the non-working app, the lookups to see if the user already exists fail. Due to this, the call to get the user's information and associated models then also returns incorrect results. Subsequent logins with existing accounts then create duplicates.

I don't have extensive experience in sysadmin and Node, so please assume beginner knowledge in those two categories.

Are there any compelling things that jump out as reasons that the API would succeed or fail in UNIX vs. Linux / other environmental factors?

The apps (working and nonworking) use MongoLab. I have also tried swapping MongoLab out for a local MongoDB instance, but had the same results (fine on local, broken on VPS).

Thank you for any insight or help!!

Be the first one to answer this question.