I'm new(ish) to coding and new to Node.js. I am also new to Macs and its all a bit confusing. I am trying to install Mongodb.
I have successfully installed mongodb into my project folder using
npm install -s mongodb
I am following a tutorial video which makes this a little frustrating.
I have tried to connect to my database (which is being hosted on mlab) using:
var mongoose = require('mongoose')
var dbUrl = 'mongodb://user:user@ds119070.mlab.com:19070/runticle'
mongoose.connect(dbUrl, (err) => {
console.log('mongo db connection', err)
})
When I run the code, I get the message
mongo db connection { MongoNetworkError: failed to connect to server [ds119070.mlab.com:19070] on first connect [MongoNetworkError: connect ECONNREFUSED 54.72.66.253:19070]
at Pool. (/Users/alfie/Desktop/code/Lindacourse/mygod/node_modules/mongodb-core/lib/topologies/server.js:505:11)
at emitOne (events.js:116:13)
at Pool.emit (events.js:211:7)
at Connection. (/Users/alfie/Desktop/code/Lindacourse/mygod/node_modules/mongodb-core/lib/connection/pool.js:329:12)
at Object.onceWrapper (events.js:317:30)
at emitTwo (events.js:126:13)
at Connection.emit (events.js:214:7)
at Socket. (/Users/alfie/Desktop/code/Lindacourse/mygod/node_modules/mongodb-core/lib/connection/connection.js:245:50)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
name: 'MongoNetworkError',
message: 'failed to connect to server [ds119070.mlab.com:19070] on first connect [MongoNetworkError: connect ECONNREFUSED 54.72.66.253:19070]' }
(node:7587) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [ds119070.mlab.com:19070] on first connect [MongoNetworkError: connect ECONNREFUSED 54.72.66.253:19070]
at Pool. (/Users/alfie/Desktop/code/Lindacourse/mygod/node_modules/mongodb-core/lib/topologies/server.js:505:11)
at emitOne (events.js:116:13)
at Pool.emit (events.js:211:7)
at Connection. (/Users/alfie/Desktop/code/Lindacourse/mygod/node_modules/mongodb-core/lib/connection/pool.js:329:12)
at Object.onceWrapper (events.js:317:30)
at emitTwo (events.js:126:13)
at Connection.emit (events.js:214:7)
at Socket. (/Users/alfie/Desktop/code/Lindacourse/mygod/node_modules/mongodb-core/lib/connection/connection.js:245:50)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:7587) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7587) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
When I try to run mongod on my terminal, it says command not found.