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.
Related
This is my first post here, let me know if I do it wrong. I would like to start by mentioning that I'm kind of a beginner developer. I've had a bunch of classes, but it's also my first time working on something of my own, from beginning to end (emphasis on "end").
I'm working on a relatively simple app, for user management (CRUD, with different levels of authorizations) and shop management. I was given the choice of the tools, framework, language, etc, to use, with the only constraints that 1/ the main device to use it will be a tablet most of the times 2/ nothing should be hosted online. I wanted to get more familiar with Javascript so I went with creating a React app (front) with Express Nodejs (back) and a MySQL database I access via Sequelize.
Development is going fine (for the most part thanks to many great posts here on SO), but I just got hit by the reality that I have never tried to build the app and see if it runs the way I intend. And I do not know how to do it. I should have researched that earlier.
So far, in development I always tested everything on PC and phone by running npm start (front end) and node server.js (back end), and the client runs in a browser (when using a phone I access the IP adress and port, like 192.168.x.x:3000). Backend listens to the 8080 port no prob, access to the MySQL database works as intended thanks to Sequelize. Frontend listens to port 3000 to display the user interface on the browser, and React makes it easy to develop features in front, and quickly troubleshoot them. Everything works fine, and as expected, anyone in the same network (and with a web browser) can access and use the app that way.
This is the behavior I want to replicate with a production build : having a computer host the build, and run the "server" so that the app is available to any device in the local network. So I guess I need to somehow make my build in a way to make it possible to turn on and off the "server" at will, maybe via a .exe ? Or turn it on at the same time as the computer ?
I know I should have researched that earlier and not doing so was a mistake. All I know is I'll have to use npm run build, to get the build folder, but I don't know what to do from there. Could you help me figure it out ? Among many things I'm not sure of, is whether or not the host computer (not mine) needs to have node.js installed ? Does it also have to have MySQL installed ? Do I make a single build that incorporates the backend and the frontend, or do I build both separately ? If so, how ?
Let me know if you need to see part of the code. Thanks in advance and have a great day.
EDIT : App was created using create react app
There are options to deploy on cloud like Cloud Servers. But I think you're looking for hosting the application on the local machine. You need to create a service, bundle the application and serve whenever you want.
Following link might be helpful
https://www.section.io/engineering-education/compile-your-nodejs-application-into-a-exe-file/
I was uploading material for a website on mongo by node previously on my windows pc. Now, I don't have much idea about the technicality of it but all I used to do was open postman, open cmd, type "node index.js", cmd would show "connected to port 3000" and when I used to upload them through postman I could see the changes in Mongo.
Now that I have switched to mac, I don't have much idea how to go about this. I installed mongo, node, and npm using homebrew but I don't know how to set up a local connection between node and mongo to upload to the database.
Any help would be appreciated. Thank you.
ok...I am actually building a APP with MERN stack on Mongodb.
A mac is not much different...sorry a mac is way different-
Postman doesn't work well with mac at all-
Infact I can't even find anything to test a backend with on a mac using Postman from their own official page.
I found this helpful for testing an app with Postman-
https://tech-cookbook.com/2020/04/27/how-to-use-postman-on-mac-os-catalina-get-request-rest-api-example/
It's hard to find sources on Google because it has become a capitalist pig for corporations to sell on....I feel you.
When I started looking for help, I ran into more buy this product than actual tech help.
You can also pull from github repositories...because mac's provide additional security for the users, it's almost guaranteed 20 additional steps in development than a windows.
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'm trying out Node.JS for the first time using MEAN.JS as a starting point. When testing on localhost, everything looks OK. However, when deploying to https://raichu-com.herokuapp.com/, I get a blank page (the header menu flashes for a moment, then goes away).
I don't see any error in my logs, and the database seems to be connected properly (users and sessions collections are created). What could probably be the issue here?
I compared local and cloud Sources, seems like there's a little difference:
Also, while irrelevant to the question, it'd be incredibly helpful if you could name me some (other) examples of cloud providers for Node.JS that you think are (more) affordable and easy to use.
teamtreehouse also has a good tutorial on getting node to work on Heroku
it lists steps like
specify the version of node in your package.json,
include a Procfile,
etc...
In Heroku var config add
NODE_ENV
development
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.