Javascript Node.js-“节点”;未捕获错误:找不到模块;redis"&引用;
我正在尝试在Node.js中使用Redis作为数据库(尽管我听说MongoDB可能更容易) 我找到了一些指向的链接,因此我使用Brunch设置了一个新的Node.js项目,并按照说明在我的项目目录中运行了以下内容:Javascript Node.js-“节点”;未捕获错误:找不到模块;redis"&引用;,javascript,node.js,redis,brunch,Javascript,Node.js,Redis,Brunch,我正在尝试在Node.js中使用Redis作为数据库(尽管我听说MongoDB可能更容易) 我找到了一些指向的链接,因此我使用Brunch设置了一个新的Node.js项目,并按照说明在我的项目目录中运行了以下内容: npm install redis hiredis 然后,我将auth.js示例中的以下内容添加到vendor/script.js var redis = require("redis"), client = redis.createClient(); 但是,当我运行brunc
npm install redis hiredis
然后,我将auth.js示例中的以下内容添加到vendor/script.js
var redis = require("redis"),
client = redis.createClient();
但是,当我运行brunch w-s时,控制台中出现以下错误:
Uncaught Error: Cannot find module "redis"
我假设这与我的项目中没有包含的模块有关,但我不确定从哪里开始。我补充说
"redis": "latest"
我的package.json文件,但这似乎没有任何作用
我还尝试通过运行
sudo npm install -g redis
但还是没有运气
我还应该补充一点,我在OS X上安装了redis server,我可以在终端上运行它:
$ 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
我做错了什么?早午餐是html5应用程序汇编程序,而不是node.js,你不能在那里要求节点模块。你的项目目录的
节点模块
子目录中有哪些子目录和文件?他们拥有正确的权限和所有者吗?@ebohlman似乎一切正常。你能require()
该目录中的任何其他模块吗?@ebohlman啊,不,我不能。当试图要求其他模块时,也会出现同样的错误。@ebohlman我不知道为什么我不能要求节点_模块中的内容。在brunch的空白安装上也尝试过这个(“brunch new projectname”),但我仍然得到了错误。