configurationrequirejs从node_modules读取

我正在尝试设置一个nodejs项目来使用requirejs。 我用node r.js ./config/main.js调用我的程序,我的main.js如下所示:

 var cs = require("coffee-script"); var requirejs = require("requirejs"); requirejs.config({ nodeRequire: require, baseUrl: ".", paths: { cs: "cs", CoffeeScript: "CoffeeScript", csBuild: "csBuild", express: "express", nohm: "nohm", redback: "redback", _: "underscore", "connect-redis": "connect-redis", freebase: "freebase" } }); console.log("hetet"); requirejs(["cs!./config/app"], function(app){ console.log("closing") }); 

和app.coffee里面:

 define((require) -> express = require("express") RedisStore = require("connect-redis")(express) app = express.createServer() config = require('cs!./config') require('cs!./setup')(app, express, RedisStore) require('cs!./routes')(app) require('cs!../src/server') app.listen(config.server.port) ) 

我似乎在main.js失败与错误:

 node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: Calling node's require("config") failed with error: Error: Calling node's require("config") failed with error: Error: Cannot find module 'config' 

我注意到当我注释掉这行var requirejs = require("requirejs"); (在main.js中),我得到了更进一步的失败,在RedisStore = require("connect-redis")(express) (在app.coffee中)错误处:

 node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ TypeError: undefined is not a function at ./config/app.coffee:10:41 

我一直有很多麻烦configuration在节点requirejs任何帮助,将不胜感激。

谢谢

       

网上收集的解决方案 "configurationrequirejs从node_modules读取"