search

Home  >  Q&A  >  body text

node.js - 为什么用NPM安装mongodb开启服务不成功?

npm install mongodb --save 安装成功后

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

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

PHPzPHPz2871 days ago639

reply all(4)I'll reply

  • 伊谢尔伦

    伊谢尔伦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

    reply
    0
  • 迷茫

    迷茫2017-04-17 14:22:35

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

    reply
    0
  • 阿神

    阿神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.

    reply
    0
  • PHPz

    PHPz2017-04-17 14:22:35

    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);
    

    reply
    0
  • Cancelreply