I am trying to connect to redis in linux using node js as below
我正在尝试使用节点js连接到linux中的redis,如下所示
var redis = require('redis');
var redis = require('redis');
But, getting the error as below. I have redis-2.4.17 installed in linux and the path is /home/masadmin/redis-2.4.17/src Kindly help on how to connect to redis using node in linux.
但是,得到如下错误。我在linux中安装了redis-2.4.17,路径是/home/masadmin/redis-2.4.17/src请教如何使用linux中的节点连接到redis。
module.js:340
throw err;
^
Error: Cannot find module 'redis'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object. (/home/masadmin/Vinod/prapprRedisLoad.js:2:13)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
2 个解决方案
#1
3
Have you installed the Node.js Redis module for your application? npm install redis (in the same directory as your application) will install it. Check out this screencast for more information.
您是否为您的应用程序安装了Node.js Redis模块? npm install redis(与你的应用程序在同一目录下)将安装它。查看此截屏视频以获取更多信息。
#2
0
I have the same error after Node.js Redis module has been installed. I've fixed it (error) after changing NODE_PATH environment variable:
安装Node.js Redis模块后,我遇到了同样的错误。我在更改NODE_PATH环境变量后修复了它(错误):
export NODE_PATH=$NODE_PATH:/node_modules