Problems with the server connection MongoDB - node.js

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.

Related

Connect to windows server from node js

I'm not very experienced in programming and have a problem that I'm finding hard do solve.
I have a web app that is on a ubuntu server, that is running on node js. That web app creates an excel file on the back-end that is to be read by another excel file and execute a vba that gives as results in a software that only runs on windows.
I tried the software on a windows server and it seems to run, so no problems there.
My question is: how do I make my web app excel file be stored in the windows server and how do I call the files on that server to run from node js?
Can anyone please share some resources on where I can explore this subject please?
Thanks in advance,
Ana
The following is what I advised the OP to do in the comments, only longer and with more explanation.
First, install NodeJS on your Windows server. You can do it by either installing it from the official Downloads page from NodeJS, or use a version manager such as nvm, with a Microsoft tutorial on how to do it that way. This step is up to you.
Host your back-end part (the one that creates the excel part) on the Windows server. That way, the file will be stored in the same filesystem the "software that runs only on Windows" is on.
The problem now is determining if there is any way to run the "software" via command line. Since I don't know the software name, I can't look that up but if it can, you'll have to check child processes via NodeJS.
Now, if this software has no way to be run via command line, and if they didn't publish any sort of programming interface (what is called API in the real definition of the term), chances are that you will not be able to achieve what you want to.
If you want me to clarify or explain more on some points, please let me know in the comments so I can edit my answer.

File structure for Node.js and MongoDB

I am currently learning Node.js and MongoDB for an open source project.
How should they be located in relation to one another as far as their source files?
MongoDB defaults the data folder to root, but I have MongoDB itself installed in a sub directory. Node.js in installed in yet another sub directory on same drive.
Do they need to be located in same location, or does that not matter?
Thanks for any clarification, didn't see this anywhere in the tutorials I am learning from.
No. It doesn't matter.
When you use the mongo client to connect to the mongoDB server, you already specified a host & port of that mongodb instance (this is what matters).
To use mongoDB in nodeJS: http://mongodb.github.io/node-mongodb-native/2.2/api/.
Hope it helps

Developing locally using express, mongodb and mongoose

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.

MongoDB accessible through localhost but not 127.0.0.1

I am trying to run a web application locally that uses grunt and mongodb. The app allows users to upload information which they can then view in their gallery.
started mongodb with mongod --port 3000 --httpinterface
(As mentioned in the comments, I have tried running it without the --httpinterface as well)
browsing to 127.0.0.1:3000 gives a page with only the text "It looks like you are trying to access MongoDB over HTTP on the native driver port."
browsing to localhost:3000 loads my application
the application sends data over 127.0.0.1, and it is not going through
It seems very relevant to what is going on in this question.
I hope this will not be considered a duplicate, because after finding that question I tried to work through the answers offered without success. If I was able I would have tried pursuing this issue in the comments there.
Following the answers on that question I tried running mongo with a config file without success (no config file existed beforehand, I tried to create one with the sample offered on the mongo website but it rejects it). I also tried deleting the lock files and repairing mongo. Nothing has changed.
It's probably worth mentioning that the application I'm working with is an existing, sparsely documented project that was given to me for a school assignment. It is far more complicated than anything I have ever worked on and I am very unfamiliar with tools like mongo.

Register, login, logout Website with Node

I'm currently moving on with reading about node. I'm getting through the tutorials well using the command line. However I am thinking ahead and I want to create a simple register, log in and log out website.
Where would I place the node files on a server (all examples I see run from local host:3000)?
What is the best tutorial for creating this type of website from scratch with node?
Thanks in advance!
It doesn't really matter where you put the files on the server. The localhost:3000 bit comes from the fact that your core server file tells the server to listen on that port.
I would recommend using the express-generator from npm. It's pretty versatile and does a lot of the leg work.
Just run the following:
npm install express-generator
After installing, you'll need to just run the following to create a new web app:
express
The details are here: http://expressjs.com/starter/generator.html.
Also, try to read through and understand all of the pre-provided code.

Resources