Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install mongo/mongodb in VS Code

Im trying to build a REST API. First of all, I have to set up my environment ( MongoDb and Nodejs ) and a text editor . I've choosen VS Code. I opened my Integrated Terminal. I installed mongo using this command ( npm install mongo ). And to be sure I installed twice using instructions from the mongdb documentation ..

However , when I'm typing out a command ( npm mongo --version ) it says that "mongo " is not an internal command . It means that mongo does not exist. I'm getting confused and I need help!!

like image 592
Zakaria Belassal Avatar asked Jan 28 '26 19:01

Zakaria Belassal


2 Answers

You are trying to access the mongo command from outside, for that you have to add the mongo executable to PATH.

Search for your MongoDb installation bin folder and copy the path (MongoDB executables will be found in "C:\Program Files\MongoDB\Server\4.0\bin").

Right click My Computer > Properties > Advanced system settings > Environment Variables > System variables > Look for "Path" > Edit > New > Paste in the path to your Mongodb bin folder > Restart your terminal.

Hope this will help you :)

UPDATED

I think you have not installed the extension for handling your database.

Refer here for installing extension Azure Cosmos DB extension and establishing the connection with local Mongo server.

like image 195
Vijay Rajpurohit Avatar answered Jan 31 '26 16:01

Vijay Rajpurohit


Installation of MongoDB have nothing relevant with npm commands, especially with mongo package.

First of all, you should decide what version of MongoDB you'd like to use: Atlas or Community. If you decide to use Community you should download it to your local machine from this part of official MongoDB site, after installation, check out this manual, and then try to use Mongo Shell. And create a DBA (root) account for your database, you can find more info about it in official doc part, or here: in my answer for this question.

Right after correct installation, you should choose to decide what driver for Node.js you will use. Most of users decide between native Mongo Driver and mongoose And this is where npm or yarn comes out of darkness. You could install native mongoDB driver via: npm install mongodb --save or mongoose via: npm install mongoose. Try to choose wisely.

like image 41
AlexZeDim Avatar answered Jan 31 '26 15:01

AlexZeDim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!