node.js - 为什么用NPM安装mongodb开启服务不成功?
PHPz
PHPz 2017-04-17 14:20:35
0
4
630

npm install mongodb --save 安装成功后

mongod --dbpath=/data --port 27017
然后提示:
'mongod' 不是内部或外部命令,也不是可运行的程序或批处理文件。

我去找了下发现都没有安装到 mongod 这个CMD
G安装也没用,到底是为什么?

PHPz
PHPz

学习是最好的投资!

reply all(4)
伊谢尔伦

The mongodb installed by npm is just a plug-in for the nodejs program to communicate with mongodb, and mongodb itself needs to be installed by yourself. The installation method is different depending on the system. You can go to the mongodb official website to read the documentation

迷茫

Let’s first figure out what npm is...

阿神

https://www.mongodb.com/download-center#community

npm installs the mongodb module of nodeJs. First, you need to install mongodb separately on your computer.

After installation, go to your installation directory and find the bin/ folder. Open the command line and enter mongod --dbpath=/data
This directory /data folder needs to be created by yourself.

PHPzhong

nodeJS uses mongooose module
brew install mongodb or other installation methods

mongoose installation

npm install mongoose --save

js code

var mongoose = require('mongoose');
var dbUrl = 'mongodb://localhost/movie';
mongoose.connect(dbUrl);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template