Closed hackerunet closed 6 years ago
The error is related to MongoDB not being accessible. Are you running mongo on your server and passing the correct address to the production
key of config.js
?
To use npm start, you need to set the environment variables on your server. I don't know much about Azure, but a quick search led me to this page: https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-how-to-specify-environment-variables
I'm not aware if more env variables in config.js, all I have is those posted before and also my database is in local env I can access using the npm run dev without issues. I think the documentation is not enough for people that are not totally familiar with spliting configurations with nodejs, like myself, can you please give me a full list of needed variables and where to place them to be able to change between envs ?? I was developing using npm run dev, now I can run npm run prod but after it, I'm also trying in linux running the script with node . but it throws errors. Is totally necessary to run this restful application using npm only?? If I don't use npm to run the scripts is there any possibility that the application missed all config variables just calling node . ??? Another question I have is, what exactly the npm run prod does? does it minimize any JS file? how can we get this to production and of course optimizing the performance?? Thanks
First, the error is related to MongoDB. It has nothing to do with env vars. You need to set it up on your server and put the correct address into config.js
.
I was just talking about env vars because the .env
file will not work on your server (Azure, AWS, Heroku etc.). You need to set env directly there. You can watch the video where I set it on Heroku.
What's the ENV variable name to properly configure mongo db uri and options from config.js file? that's not in the README and of course is obvious for most developers but not as clear for newbies like myself, but, I was trying to add mongo.uri in config.js and didn't work, I'm receiving undefined URI in mongoose service which means cannot load the ENV variable to connect to the database when I switch to prod
You need to set MONGODB_URI
or change config.js
: https://github.com/diegohaz/rest/blob/master/generators/app/templates/src/config.js#L62-L68
Hi there, I've been always running this app in dev mode, and now I'm stuck trying to get it to production, so I have some configs in the .env file to make it run but if I run for example npm run prod it , it runs without issues but if I try to run directly with node . I got this error:
I need to run this app calling app.js directly because it's going to be run using azure and iisnode server, so I'm going to attach my current .env file maybe you can see if there is any missing configs