1

我是新手node.js(但有 10 年的 C# 经验)我有以下代码

var http = require("http");
var url = require("url");
var path = require('path');
var fs = require("fs");
var express = require("express");
var mongo = require("./node_modules/mongo");
var Server = mongo.Server;
var Db = mongo.Db;
var server = new Server('localhost', 27017, {auto_reconnect: true});
var db = new Db('mydb', server);

我得到这个例外:

错误:找不到模块“./node_modules/mongo”

at Function.Module._resolveFilename (module.js:338:15)

我也试过:

var mongo = require("mongo");
4

1 回答 1

1

试试这个:

var mongodb = require('mongodb');
于 2012-11-04T14:34:07.133 回答