2012-08-17 107 views
2

我试图在Node.js中使用Redis作为数据库的build a simple "Twitter" style short messaging app(虽然我听说MongoDB可能更容易)...Node.js - “未捕获的错误:找不到模块”redis“”

我发现,点我的https://github.com/mranney/node_redis的方向,所以我设置使用早午餐一个新的Node.js项目,跑在我的项目目录下面的指示几个环节:

npm install redis hiredis 

我然后将auth.js示例中的以下内容添加到vendor/script.js中

var redis = require("redis"), 
client = redis.createClient(); 

然而,当我跑的早午餐W¯¯-s我在控制台中出现以下错误:

Uncaught Error: Cannot find module "redis" 

我假设它的东西做的模块没有被纳入到我的项目,但我我不确定从哪里开始。我加

"redis": "latest" 

我的package.json文件,但似乎并没有做任何事情。

我也试图通过运行

sudo npm install -g redis 

但仍没有运气全球安装Redis的模块。

我还要补充一点,我在OS X上安装了Redis的服务器,我可以在终端运行:

$ redis-server 
[2221] 17 Aug 10:48:42 # Warning: no config file specified, using the default config. In  order to specify a config file use 'redis-server /path/to/redis.conf' 
[2221] 17 Aug 10:48:42 * Server started, Redis version 2.4.13 
[2221] 17 Aug 10:48:42 * The server is now ready to accept connections on port 6379 
[2221] 17 Aug 10:48:42 - 0 clients connected (0 slaves), 922304 bytes in use 
[2221] 17 Aug 10:48:47 - 0 clients connected (0 slaves), 922304 bytes in use 

我的应用程序目录是一个标准的早午餐安装 -

app 
config.coffee 
generators 
node_modules 
package.json 
public 
README.md 
test 
vendor 

我在做什么错?

+1

哪些子目录和文件位于项目目录的'node_modules'子目录中?他们是否拥有正确的权限和所有者? – ebohlman 2012-08-17 19:18:32

+0

@ebohlman http://i.imgur.com/0GqT0.png – 2012-08-17 21:03:10

+0

这似乎都是为了。你能否要求()该目录中的任何其他模块? – ebohlman 2012-08-17 21:56:01

回答

1

早午餐是html5应用程序汇编程序,而不是node.js,您不能在那里需要节点模块。

相关问题