5

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

4
  • 2
    "I added node-redis..." – Might be I misunderstand but if you wrote "node-redis" in your package-json it should be just "redis". Commented Oct 15, 2013 at 9:12
  • @AndreasHultgren if you look closely, you'll see that the module is, in fact, redis. Commented Oct 15, 2013 at 9:32
  • @FlorianMargaine If I look closely where? I can't see his package.json. It seems very plausible to me that one might mistakenly write the wrong name and not notice the error since there's also the node-redis module. Commented Oct 15, 2013 at 9:55
  • @AndreasHultgren if you look closely at the link he showed: github.com/mranney/node_redis Commented Oct 15, 2013 at 10:01

1 Answer 1

3

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 cding 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.