getting-MEAN-2
getting-MEAN-2 copied to clipboard
Setting NODE_ENV value on windows
Hi Simon. I'm on page 157 of then 2nd edition of Getting-Mean and I'm having an issue with the section:
TESTING BEFORE LAUNCHING
When I try to run the following command
NODE_ENV=production MONGODB_URI=mongodb://<username>:<password>@<hostname>:<port>/<database> nodemon
in my console I get the following error:
'NODE_ENV' is not recognized as an internal or external command, operable program or batch file.
I'm on a windows machine and I'm pretty sure that the problem is that I'm running from a command prompt. I found the following stack overflow question. https://stackoverflow.com/questions/11928013/node-env-is-not-recognized-as-an-internal-or-external-command-operable-comman/40967643#40967643
I was wondering what you recommend here?
Seems like a lot of people recommend https://www.npmjs.com/package/cross-env
But I'm not sure if that will allow me to test my mLab database locally. I'm pretty sure I have all my code correct. And I set up the database in heroku (using mLab) with no issues. But I want to make sure I can properly connect to that remote database before moving on to chapter 6.
Thank you.
I was able to solve this by using the following command in my command prompt.
heroku logs
This let me see all the console logs in my application during the build. I saw the following line.
2020-04-01T02:25:15.468604+00:00 app[web.1]: Mongoose connected to mongodb:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
So I know that it connected successfully. I'm following up with this comment in case anyone else runs into this issue.
Love the book btw.
EDIT
And I'm seeing that if I had read 1 more page, I would have noticed that you actually mention this. Page 158 mentions that you can use heroku logs to make sure it connects like it should. Whoops.