'Can't open mongo shell in Terminal or when trying to start express.js server

I am trying to use express.js to create a API server for a project I want to build using MongoDB. But when I attempt to run mongosh in the terminal to check and clean up old databases I get this error message in the terminal image below, I am having difficulties trouble shooting.

Attempt to open Mongo shell

I have ran mongod too but I am not sure if this was successful in starting the local servers.

Running mongod + response

I've used express before for a previous project that has been deployed on mongoDB so I was not expecting to run into this issue.



Solution 1:[1]

I had to start mongodb-community with:

brew services start mongodb-community

Solution 2:[2]

you can use chaining operator like this

<p>this.props.query?.query?.id</p> //This line throws an error

or first verify then print

{ this.props.query && this.props.query.query &&
<p>this.props.query.query.id</p> 
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mayur Kumar
Solution 2 titleLogin