快递js中的require语句会抛出错误

时间:2015-10-12 07:47:19

标签: node.js express

var express = require('express')
, signup = require('./routes/signup')
,login=require('./routes/login')  
, http = require('http')
, path = require('path')
, cal=require('./routes/calculate')
, db = require('./routes/db')

, ejs = require('ejs')
, moment = require('moment')
, mysql = require('mysql');
var pool  = require('pooling');

var app = express();
pool.initializepool(10);


// all environments
 app.set('port', process.env.PORT || 3000);
 app.set('views', path.join(__dirname, 'views'));
 app.set('view engine', 'ejs');

当app.js中提到这个时,var pool不会抛出错误。但是当在更平滑的节点js文件中提到相同的行时,它会抛出错误,指出无法找到模块“池化”。 这是我的db.js文件

 var mysql = require('mysql');
 var pool  = require('pooling');
 exports.validate= function(callback,email,password)
{
var connection=pool.getConnection();
var connection=connect();
  }

请帮忙

1 个答案:

答案 0 :(得分:0)

确保池有一个module.exports(它必须有bcoz才能在app.js中获取它)

然后确保相对路径正确,如" ./ routes / login"

希望这有帮助

print(info["set1"]![2])