Reputation: 5977
I have installed a module node-redis (https://github.com/mranney/node_redis) locally in my express application. I added node-redis to my package.json and ran npm install. The module got installed. But if i start the node REPL and do
var redis = require("redis")
I get
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:364:17)
at require (module.js:380:17)
at repl:1:13
at REPLServer.self.eval (repl.js:110:21)
at repl.js:249:20
at REPLServer.self.eval (repl.js:122:7)
at Interface.<anonymous> (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
How can i fix this?
Thank You
Upvotes: 5
Views: 9540
Reputation: 60835
You have to start the node REPL in a folder where it can look for the redis
package. If you installed redis
in your local installation, be sure to run the node REPL from the local installation folder.
For example, if you installed redis
in C:\Users\Jim\Projects\project1
, you need to run node after cd
ing into this folder.
On a side note, learn how to use npm install redis --save
. This will install redis
locally, and add the dependency in your package.json file.
Upvotes: 3