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
├─┬ connect@1.8.1
│ ├── formidable@1.0.8
│ ├── mime@1.2.4
│ └── qs@0.4.0
├─┬ express@2.5.1
│ ├── mime@1.2.4
│ ├── mkdirp@0.0.7
│ └── qs@0.4.0
├─┬ simpledb@0.0.7
│ └─┬ aws-lib@0.0.5
│ ├── UNMET DEPENDENCY sax 0.1.x
│ └── UNMET DEPENDENCY xml2js 0.1.x
└─┬ socket.io@0.8.7
├── policyfile@0.0.4
├── redis@0.6.7
└─┬ socket.io-client@0.8.7
├── uglify-js@1.0.6
├── websocket-client@1.0.0
└── xmlhttprequest@1.2.2
[ec2-user@ip-10-196-170-34 ~/nodeapp]$ npm list -g
/usr/local/lib
├─┬ connect@1.8.1
│ ├── formidable@1.0.8
│ ├── mime@1.2.4
│ └── qs@0.4.0
├─┬ express@2.5.1
│ ├─┬ connect@1.8.1
│ │ └── formidable@1.0.8
│ ├── mime@1.2.4
│ ├── mkdirp@0.0.7
│ └── qs@0.4.0
└─┬ npm@1.0.106
├── abbrev@1.0.3
├── graceful-fs@1.0.1
├── ini@1.0.1
├─┬ minimatch@0.0.4
│ └── lru-cache@1.0.4
├── node-uuid@1.2.0
├── nopt@1.0.10
├── proto-list@1.0.0
├── request@2.1.1
├── rimraf@1.0.8
├── semver@1.0.11
├── slide@1.1.3
└── which@1.0.2
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
connect is a module that you should be
requireing from your own program that creates the server, etc, like:Put that in a file like server.js, then you can call: