Jump to content
smus

Node.js + MongoDB

Recommended Posts

I'm new to Node.js and MongoDB. I can't run Mongo on Node as it is explained here in w3 reference. 

There's an error 471 when I run 'node install mongodb'

 

Share this post


Link to post
Share on other sites

I don't think Node has error codes like that, 471 is probably a line number or something.  What is the actual error message?  Have you installed the mongodb packages before trying to install them on Node?

Share this post


Link to post
Share on other sites

You should be using NPM (which is what the example shows)

https://www.w3schools.com/nodejs/nodejs_mongodb.asp

$ npm install mongodb

 

To elaborate, Node is the JavaScript runtime environment, NPM is the package manager.  Using NPM to install Node packages for your project.

Share this post


Link to post
Share on other sites
11 hours ago, justsomeguy said:

I don't think Node has error codes like that, 471 is probably a line number or something.  What is the actual error message?  Have you installed the mongodb packages before trying to install them on Node?

Exactly! When I type "npm start" - this is the number of line in module.js file. There goes "Cannot find module 'express'" and then the same errors like in the previous message.

Share this post


Link to post
Share on other sites

Program files is a protected directory, did you open command prompt by right clicking it and selecting 'run as administrator'.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, dsonesuk said:

Program files is a protected directory, did you open command prompt by right clicking it and selecting 'run as administrator'.

Running as an admin:

npm install mongodb - without errors

npm start - the same error

Share this post


Link to post
Share on other sites

No, I didn't install it. Now after npm install and npm install mongodb, npm start shows connection errors with mongodb - failed to connect to a server localhost:27017

Share this post


Link to post
Share on other sites

Depending on version you used, you have to create a db folder which will hold database data, and configure the path to that folder, I should check documentation for your version to identify proper procedure for configuring. A pc restart may be required.

Edited by dsonesuk

Share this post


Link to post
Share on other sites

I've no idea where to configure an address of the db folder. I've installed node.js using Windows installer (from *.msi file). But MongoDB has been installed manually from zip file.

Share this post


Link to post
Share on other sites

Then where you got zip file MUST have documentation on how to setup database data folder? and configure on where this path should be placed, test it connects, and port to use. There are several ways to do this, apparently in programs folder, or on main drive under C:\ in it own folder.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×