I'm currently making an app using express, mongodb and mongoose, and I'm running it locally on my machine. My problem is that if I'm not connected to the internet the app won't run at all due to the app not being able to connect to mongodb server.
I thought that if I ran the mongodb server locally on my computer along with the app then I wouldn't need an internet connection, or is my understanding wrong?
Any help would be much appreciated.
The answer is: yes.
If you install MongoDB locally then you won't need internet connection to access it.
Make sure that your connection string contains "localhost".
Also, make sure that you don't need anything else on the internet, and that you run npm install while you are connected to the internet, or otherwise your dependencies (like mongoose) won't get installed. After they are installed they can work without the internet connection just fine - if your database is on localhost.
Also, make sure that your local MongoDB server is running. You can run:
mongo test
in the command line to see if you can connect to a local database.
You're in the right path !
Here's the thing, you need to get yourself a copy of MongoDB, you can download and install the suitable version to your system from here.
Now you need to configure MongoDB in your in your path so you can launch it when you is or simply add it a process that will launch when your system starts.
In order to configure please choose the suitable conf to your system :
Windows.
Linux.
macOS.
Then, before running your application, make sure MongoDB is running in the background ad service or daemon and then simply launch your application.
Related
I start work on fresh application of MeteorJs and facing problem with mongoDB connection with application and have research a lot regarding this but not get any proper solution.
I need to connect my MeteorJs Application with MongoDB and research about this issue but didn't get any solution.
If you are using Meteor Cloud then you should stick to the official docs: https://galaxy-guide.meteor.com/mongodb.html#authentication
If you are using Meteor-Up (MUP) then you should check out the Mongo configuration: https://meteor-up.com/docs.html#mongodb
If you want to connect to a MongoDb with a custom deployment or your local development setup then you need to properly configure the MONGO_URL: https://docs.meteor.com/environment-variables.html#MONGO-URL
Don't forget to configure MONGO_OPLOG_URL as well: https://docs.meteor.com/environment-variables.html#MONGO-OPLOG-URL
I'm fairly new to React-native. Im sorry about quite a convoluted question but I have dilemma. I am building an API that communicates with a server app that Im working on, I have been using Docker successfully to run containers BUT I'm constantly being told that I don't need to run Docker at all. I understand the principles of Docker and Node.JS but in all honesty I cant imagine how I would run server side without Docker. Ive tried Node.js and seemed to require a PHP server, which I was also told I did not need. Is this true? which is better Docker or Node.JS? and If Node JS is better how to run it without a php server as it is my understanding that php serves the pages and React consumes the pages.
'You can just install Node, frequently through your OS's package manager. It doesn't require PHP or other language interpreters. I find working directly with Node much easier than using Node in Docker: it is actually a local development environment that my IDE is comfortable with, and not a path to run a Node interpreter "somewhere else" that's isolated from my desktop tooling. '
1)After a few weeks of research I found that I didn't need docker at all. Within Node is the ability to run a server using either fastify or express. I just needed to check on the relevant documentation for usage
2) I linked fastify to ngrok and exposed my local IP address to a public facing direction
3) I linked the ngrock url to my freedns and voila! it worked!
4) I had a small problem with the port which was resolved by using
the command ngrok http 127.0.0.1:5000
I'm using the remote database URL on my laptop and it works perfectly on localhost. When I upload to heroku, it won't save new users to the database. It's still connecting to the database to start the web application (I think). I see the 'session' storage increasing by one every time I visit the website online. And I can definitely create new users and do everything it's supposed to on my laptop.
I've tried changing versions of the database from mongodb 2.6 to 3.0. I've tried switching out versions of mongoose so that they're compatible with the version of mongodb (http://mongoosejs.com/docs/compatibility.html).
I've tried deleting node_modules and doing a fresh npm install.
Been debugging this for months and have probably put over 100 hours in to it with no solution. Can someone please help? I have no idea why the database would work on this machine but not the heroku server. All I've figured out so far is that the reason it's not working is the database won't create documents from heroku.
I am trying to deploy an application prototype to openshift. It works locally with mongodb at 127.0.0.1. I am trying to get it to respect process.env.OPENSHIFT_MONGODB_DB_URL when in the openshift environment but that variable is not accessible to my nodejs cartridge at runtime.
I can see that it is being set in my application's shell environment. When I do rhc ssh and then export I see OPENSHIFT_MONGODB_DB_URL=[full_url_with_password] and it all looks good.
But when, in my node.js application, I call process.env.OPENSHIFT_MONGODB_DB_URL it returns undefined.
To double check, I did a console.log(util.inspect(process.env)) from within my node.js app, and what I saw was different from what I see within my appication's secure shell. No OPENSHIFT_MONGODB_* variables were in the environment that is exposed to my node.js app.
How can I access variables across different cartridges? Or is this a configuration error?
It sounds like a configuration error. I have a similar application and
console.log(util.inspect(process.env))
gives me a clear picture of the mongodb environment variables.
The developers page indicates that:
Database environment variables pertain to a database, if one exists, and are used to connect an application to a database. Note that these connections are only available to an application internally; you cannot connect from an external source.
This suggests, to me, that the nodejs is external to the mongodb installation. I have an idea that it can be verified with the command:
rhc app show OPENSHIFT_APP_NAME
It might lead to the source of the problem. A correctly configured app would have nodejs and mongodb in this list.
I am a beginner in MongoDB and MAC OS X. I have a web based project using Node.Js-JadeExpress-MongoDB.
After 3 weeks, finally I can integrated JadeExpress and Node.js via terminal, but the problems still come with MongoDB server. Each time i want to connecting a MongoDB server via terminal, i have to create a file bashrc by vim editor.
Inside that, I have to put this code :export PATH=<mongodb-install-directory>/bin:$PATH .
I use this tutorial as a reference:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/
Does anyone know what I have to do to connecting to the MongoDB server efficiently?
If you are not very familiar with command line interface then I would say just take all the mongodb binaries from the mongodb/bin/ folder and put them in /usr/bin/ folder. So that you don't have to modify PATH at all.
Not the most efficient way but will solve your problem.