Kato
Kato

Reputation: 40582

Can't start node.js app with Connect (Cannot find module '/home/ec2-user/nodeapp/connect')

I'm trying to figure out how to utilize the Connect module to start my node application, but can't seem to call connect

Please note that I'm attempting to utilize the commands described here, as "init.d" friendly start, stop and restart commands, not to utilize Connect inside an existing app.

[ec2-user@ip-10-196-170-34 nodeapp]$ node connect
node.js:116
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: Cannot find module '/home/ec2-user/nodeapp/connect'
    at Function._resolveFilename (module.js:299:11)
    at Function._load (module.js:245:25)
    at Array.<anonymous> (module.js:402:10)
    at EventEmitter._tickCallback (node.js:108:26)

Everything I could think of that might matter:

[ec2-user@ip-10-196-170-34 ~/nodeapp]$ uname -a
Linux ip-10-196-170-34 2.6.35.14-103.47.amzn1.x86_64 #1 SMP Fri Nov 18 04:03:11 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

[ec2-user@ip-10-196-170-34 ~/nodeapp]$ node -v
v0.4.2

[ec2-user@ip-10-196-170-34 ~/nodeapp]$ express -v
2.5.1

[ec2-user@ip-10-196-170-34 ~/nodeapp]$ npm -v
1.0.106

[ec2-user@ip-10-196-170-34 ~/nodeapp]$ npm list
/home/ec2-user/nodeapp
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│   ├── UNMET DEPENDENCY sax 0.1.x
│   └── UNMET DEPENDENCY xml2js 0.1.x
└─┬ [email protected]
  ├── [email protected]
  ├── [email protected]
  └─┬ [email protected]
    ├── [email protected]
    ├── [email protected]
    └── [email protected]

[ec2-user@ip-10-196-170-34 ~/nodeapp]$ npm list -g
/usr/local/lib
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
└─┬ [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├─┬ [email protected]
  │ └── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  └── [email protected]

One suggestion was to simply run connect from the command line with no node prefix:

[ec2-user@ip-10-196-170-34 nodeapp]$ connect
-bash: connect: command not found

Upvotes: 0

Views: 1165

Answers (1)

Daniel Dickison
Daniel Dickison

Reputation: 21882

connect is a module that you should be requireing from your own program that creates the server, etc, like:

var connect = require('connect');
var server = connect.createServer(...);

Put that in a file like server.js, then you can call:

node server.js

Upvotes: 1

Related Questions