For the last couple weeks I’ve been playing around with Glitch.com. I don’t have much experience with Node.js, so it’s been a good way to learn more about Node.js without having to setup anything locally.
Glitch’s web based code editor is pretty good, but it’s still not the same as using a local editor, so I decided to export my project and develop it locally. It’s easy enough to export a project, but the exported project didn’t work right away.
Starting the project, I got the error:
Error: OAuth2Strategy requires a clientID option
I’m using the
passport-oauth package and I discovered that the secrets I saved in the .env file on Glitch weren’t being loaded in my local environment. Instead of using the .env file in the project, Node.js uses the variables in the .bash-profile file. You can view those environment variables by adding this line to your project:
To fix the issue with the project exported from Glitch, one option is to move your secrets to the .bash-profile file, but that can get messy, so another option is to use the
dotenv npm package.
Add it to your app with:
npm install dotenv --save
And then ensure that it’s referenced in your project with: