Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web_server.js: Cannot find module 'redis' #37

Closed
peepo opened this issue Nov 9, 2010 · 19 comments
Closed

web_server.js: Cannot find module 'redis' #37

peepo opened this issue Nov 9, 2010 · 19 comments
Labels

Comments

@peepo
Copy link

peepo commented Nov 9, 2010

node v0.3
redis v2.2 antirez git

wfm most test.js

at resolveModuleFilename (node.js:265:13)
at loadModule (node.js:231:20)
at require (node.js:291:14)
at Object. (/Users/jaymini/node_redis/examples/web_server.js:4:20)
at Module._compile (node.js:348:23)
at Object..js (node.js:356:12)
at Module.load (node.js:279:25)
at Array. (node.js:370:24)
at EventEmitter._tickCallback (node.js:42:22)
at node.js:634:9

@mranney
Copy link
Contributor

mranney commented Nov 9, 2010

You need to install the library into your path somehow. I use npm. So from the top level node_redis dir, do:

npm install

It'll install node_redis using the local git repo as the source instead of the npm server's version.

@peepo
Copy link
Author

peepo commented Nov 9, 2010

sorry to be dim, but what library?
had various permissions problems with npm,
no doubt to be revisited..
read: api.html#modules
but not clear to me what redis file is to be linked to?

@mranney
Copy link
Contributor

mranney commented Nov 9, 2010

It's worth taking the time to figure out npm. Many node libraries only work properly from npm.

Until you get npm working, you can modify the examples to do:

require("../index");

instead of

require("redis");

@peepo
Copy link
Author

peepo commented Nov 9, 2010

result: permission denied

successfully installed npm in ~/local/bin

as per your instruction:
mac-mini:node_redis jaymini$ ~/local/bin/npm install
npm info it worked if it ends with ok
npm info using npm@0.2.7-2
npm info using node@v0.3.0
npm info preinstall redis@0.3.6
npm info install redis@0.3.6
npm info postinstall redis@0.3.6
npm info predeactivate redis@0.3.6
npm info deactivate redis@0.3.6
npm info postdeactivate redis@0.3.6
npm info preactivate redis@0.3.6
npm info activate redis@0.3.6
npm info postactivate redis@0.3.6
npm info build Success: redis@0.3.6
npm ok
mac-mini:node_redis jaymini$

but:
mac-mini:examples jaymini$ ~/local/bin/node web_server.js

node.js:63
throw e;
^
Error: Cannot find module 'redis'
at loadModule (node.js:275:15)
at require (node.js:411:14)
at Object. (/Users/jaymini/node_redis/examples/web_server.js:4:20)
at Module._compile (node.js:462:23)
at Module._loadScriptSync (node.js:469:10)
at Module.loadSync (node.js:338:12)
at Object.runMain (node.js:522:24)
at Array. (node.js:756:12)
at EventEmitter._tickCallback (node.js:55:22)
at node.js:772:9
mac-mini:examples jaymini$

the redis aspect is escaping me...

mac-mini:~ jaymini$ /local/bin/npm install redis
npm info it worked if it ends with ok
npm info using npm@0.2.7-2
npm info using node@v0.3.0
npm info preinstall redis@0.3.6
npm info install redis@0.3.6
npm info postinstall redis@0.3.6
npm info predeactivate redis@0.3.6
npm info deactivate redis@0.3.6
npm info postdeactivate redis@0.3.6
npm info preactivate redis@0.3.6
npm info activate redis@0.3.6
npm info postactivate redis@0.3.6
npm info build Success: redis@0.3.6
npm ok
mac-mini:
jaymini$ cd node_redis/

when I had tried to install it from within redis:

mac-mini:redis jaymini$ ~/local/bin/npm install
npm info it worked if it ends with ok
npm info using npm@0.2.7-2
npm info using node@v0.3.0
npm ERR! Error installing .
npm ERR! Error: ENOENT, No such file or directory 'package.json'
npm ERR! at node.js:634:9
npm ERR! Report this entire log at http://github.com/isaacs/npm/issues
npm ERR! or email it to npm-@googlegroups.com
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm not ok
mac-mini:redis jaymini$ cd ~

@mranney
Copy link
Contributor

mranney commented Nov 9, 2010

This looks like more of an npm issue. You can often find isaacs on freenode IRC, channel #node.js. That's often the fastest way to fix npm issues.

If he's not there, sending email to the npm google group address is another way to get support.

@peepo
Copy link
Author

peepo commented Nov 9, 2010

as he says there's no package.json in the folder:
https://github.com/isaacs/npm/issues/issue/353

but I'm not clear what to do next...
try a different redis package?

@mranney
Copy link
Contributor

mranney commented Nov 9, 2010

Hmm, that's odd. There is certainly a package.json file in the git repo:

mjr:~/work/node_redis (master)$ ls -l
total 200
-rw-r--r--   1 mjr  staff  15613 Nov  2 15:06 README.md
-rw-r--r--   1 mjr  staff   2078 Sep 20 09:41 bench.js
-rw-r--r--@  1 mjr  staff    568 Nov  3 12:46 changelog.md
drwxr-xr-x  12 mjr  staff    408 Nov  3 14:03 examples
-rw-r--r--@  1 mjr  staff  28257 Nov  8 16:37 index.js
-rw-r--r--@  1 mjr  staff   5421 Nov  2 15:18 multi_bench.js
-rw-r--r--@  1 mjr  staff    490 Nov  3 12:44 package.json
-rw-r--r--@  1 mjr  staff  33788 Nov  3 12:41 test.js
drwxr-xr-x   4 mjr  staff    136 Sep 24 13:15 tests

And also:

https://github.com/mranney/node_redis/blob/master/package.json

@peepo
Copy link
Author

peepo commented Nov 9, 2010

yes, but isn't that in node_redis, not redis?

@peepo
Copy link
Author

peepo commented Nov 9, 2010

ie as per issue description: Cannot find module 'redis'
presumably redis module is needed?

@mranney
Copy link
Contributor

mranney commented Nov 9, 2010

The project and repo are called "node_redis", but in npm it is called "redis". This means that you require "redis" and "npm install redis". If you want to install from git, you can check out the repo named "node_redis". From within that "node_redis" directory, you can do "npm install" and it should install properly.

@mranney
Copy link
Contributor

mranney commented Nov 9, 2010

BTW, are you using node and npm from homebrew? The homebrew installation seems to really confuse npm.

@peepo
Copy link
Author

peepo commented Nov 9, 2010

no homebrew, but stumped, you'll understand my confusion over redis,
okay so package.json is red herring as nothing to do for redis,
but given that mac-mini:node_redis jaymini$ ~/local/bin/npm install
reported ok, about an hour ago, why is the module not found?

@mranney
Copy link
Contributor

mranney commented Nov 9, 2010

Yeah, that's why I think this is an npm issue. Something about npm on your machine is confused. I suggest removing all traces of npm and node and install both again. Either that, or you can figure out what, exactly, is broken with npm on your computer, but starting over is probably easier.

It should look like this when you install and test:

mjr:~/work/node_redis (master)$ npm install
npm info it worked if it ends with ok
npm info using npm@0.2.7-2
npm info using node@v0.3.1-pre
npm info preinstall redis@0.3.6
npm info install redis@0.3.6
npm info postinstall redis@0.3.6
npm info predeactivate redis@0.3.6
npm info deactivate redis@0.3.6
npm info postdeactivate redis@0.3.6
npm info preactivate redis@0.3.6
npm info activate redis@0.3.6
npm info postactivate redis@0.3.6
npm info build Success: redis@0.3.6
npm ok

mjr:~/work/node_redis (master)$ node

require("redis");
{ debug_mode: false,
RedisClient: { [Function: RedisClient] super_: [Function: EventEmitter] },
createClient: [Function],
print: [Function] }

@mranney
Copy link
Contributor

mranney commented Nov 9, 2010

I should add that you probably shouldn't install the git version at all if you aren't making changes. Just get a fresh install of node and npm, and then do:

npm install redis

And you should be able to require("redis").

@peepo
Copy link
Author

peepo commented Nov 9, 2010

ok well it's getting late, so in the morning..

will delete and start again!

probably want to fork node_redis,

@peepo
Copy link
Author

peepo commented Nov 9, 2010

tx again

@mranney
Copy link
Contributor

mranney commented Nov 9, 2010

OK, cool. Good luck.

@peepo
Copy link
Author

peepo commented Nov 9, 2010

all-working now!

had not appreciated that npm used /usr/local/node, before /local/node
had to mv, then hunkydory.. really appreciate webserver.js and others...
so many node projects use jquery, and any other library to hand....

best!

@shafwanaw
Copy link

shafwanaw commented Oct 12, 2019

after I enter the command node server.js to make localhost, after I stabbed the command it comes out immediately.
"redis-server" module not found

-------------------------------------Starting server----------------------------------------------------
2019-10-12T08:09:36.456Z - error: Certificate file or key file is missing, falling back to non-SSL mode
2019-10-12T08:09:36.460Z - error: To create them, simply run the following from your shell: sh ./scripts/generate-ssl-certs.sh

internal/modules/cjs/loader.js:783
throw err;
^

Error: Cannot find module 'redis-server'
Require stack:

  • /etc/magoware/config/lib/redis.js
  • /etc/magoware/modules/mago/server/policies/mago.server.policy.js
  • /etc/magoware/config/lib/express.js
  • /etc/magoware/config/lib/app.js
  • /etc/magoware/server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:780:15)
    at Function.Module._load (internal/modules/cjs/loader.js:685:27)
    at Module.require (internal/modules/cjs/loader.js:838:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object. (/etc/magoware/config/lib/redis.js:2:19)
    at Module._compile (internal/modules/cjs/loader.js:945:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:962:10)
    at Module.load (internal/modules/cjs/loader.js:798:32)
    at Function.Module._load (internal/modules/cjs/loader.js:711:12)
    at Module.require (internal/modules/cjs/loader.js:838:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object. (/etc/magoware/modules/mago/server/policies/mago.server.policy.js:6:13)
    at Module._compile (internal/modules/cjs/loader.js:945:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:962:10)
    at Module.load (internal/modules/cjs/loader.js:798:32)
    at Function.Module._load (internal/modules/cjs/loader.js:711:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/etc/magoware/config/lib/redis.js',
    '/etc/magoware/modules/mago/server/policies/mago.server.policy.js',
    '/etc/magoware/config/lib/express.js',
    '/etc/magoware/config/lib/app.js',
    '/etc/magoware/server.js'
    ]
    }

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants