npm install mongodb --save 安装成功后
mongod --dbpath=/data --port 27017
然后提示:
'mongod' 不是内部或外部命令,也不是可运行的程序或批处理文件。
我去找了下发现都没有安装到 mongod 这个CMD
G安装也没用,到底是为什么?
伊谢尔伦2017-04-17 14:22:35
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
阿神2017-04-17 14:22:35
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.
PHPz2017-04-17 14:22:35
nodeJS uses mongooose modulebrew 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);