Deploying Express App

1k views Asked by At

Issue


I got the following folder structure:

diaryapp
  nodes_modules
    express
    jade
    mongoose
  public
  routes
  views
  app.js
  package.json

git pushing this to my Joyent Machine will cause a lot of npm errors. I can avoid them by adding mongodb and mongoose to my package.json dependencies, but the service won't start.

I know this is a very small amount of information, if you need further information specify the kind and I ll update my post.


The output:

git push diaryapp.no.de master
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 279 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Deploying node-service.
remote:     revision:  93ce2d3b81592c4c7475c0f242d54429cc511534
remote:     timestamp: 2012-01-23T16-20-45.830922239
remote: Installing node module deps (from package.json).
remote:     
remote:     > [email protected] install /home/node/node-service/releases/2012-01-23T16-20-45.830922239/node_modules/mongodb
remote:     > node install.js
remote:     
remote:     ./node_modules/mkdirp -> /home/node/local/lib/node_modules/mkdirp
remote:     ./node_modules/colors -> /home/node/local/lib/node_modules/colors
remote:     ./node_modules/qs -> /home/node/local/lib/node_modules/qs
remote:     ./node_modules/mime -> /home/node/local/lib/node_modules/mime
remote:     ./node_modules/hooks -> /home/node/local/lib/node_modules/hooks
remote:     ./node_modules/connect -> /home/node/local/lib/node_modules/connect
remote:     ================================================================================
remote:     =                                                                              =
remote:     =  To install with C++ bson parser do <npm install mongodb --mongodb:native>   =
remote:     =                                                                              =
remote:     ================================================================================
remote:     ./node_modules/mongodb -> /home/node/local/lib/node_modules/mongodb
remote:     [email protected] ./node_modules/mkdirp 
remote:     [email protected] ./node_modules/colors 
remote:     [email protected] ./node_modules/qs 
remote:     [email protected] ./node_modules/mime 
remote:     [email protected] ./node_modules/hooks 
remote:     [email protected] ./node_modules/connect 
remote:     [email protected] ./node_modules/mongodb 
remote: Starting node-service.
remote: error: Failed to start node server.
remote:     * * * tail of the service log * * *
remote:     [ Jan 23 16:20:51 Executing stop method (:kill). ]
remote:     [ Jan 23 16:20:51 Executing start method ("/opt/nodejs/service-starter"). ]
remote:     0.5.3
remote:     [ Jan 23 16:20:53 Method "start" exited with status 0. ]
remote:     [ Jan 23 16:20:53 Stopping because all processes in service exited. ]
remote:     [ Jan 23 16:20:53 Executing stop method (:kill). ]
remote:     [ Jan 23 16:20:53 Disabled. ]
remote:     * * *
remote: 
remote: Rolling back to default server.
remote: Starting node-service.
remote: Rollback succeeded.
To diaryapp.no.de:repo
   ed1f477..93ce2d3  master -> master

remote: 
remote: 
remote:    uncaught: Error: Cannot find module 'should'
remote:     at Function._resolveFilename (module.js:317:11)
remote:     at Function._load (module.js:262:25)
remote:     at require (module.js:346:19)
remote:     at Object.<anonymous> (/home/node/node-service/releases/2012-01-23T16-32-12.780436389/node_modules/mongoose/test/zzlast.test.js:2:14)
remote:     at Module._compile (module.js:402:26)
remote:     at Object..js (module.js:408:10)
remote:     at Module.load (module.js:334:31)
remote:     at Function._load (module.js:293:12)
remote:     at require (module.js:346:19)
remote:     at runFile (/home/node/node-service/releases/2012-01-23T16-32-12.780436389/node_modules/mongoose/support/expresso/bin/expresso:691:19)
remote: 
remote: 
remote:    Failures: 1
remote: 
remote: 
remote: make: *** [test] Error 1
remote: npm ERR! [email protected] test: `make test`
remote: npm ERR! `sh "-c" "make test"` failed with 2
remote: npm ERR! 
remote: npm ERR! Failed at the [email protected] test script.
remote: npm ERR! This is most likely a problem with the mongoose package,
remote: npm ERR! not with npm itself.
remote: npm ERR! Tell the author that this fails on your system:
remote: npm ERR!     make test
remote: npm ERR! You can get their info via:
remote: npm ERR!     npm owner ls mongoose
remote: npm ERR! There is likely additional logging output above.
remote: npm ERR! 
remote: npm ERR! System SunOS 5.11
remote: npm ERR! command "/opt/nodejs/v0.4/bin/node" "/opt/nodejs/bin/npm" "build" "/home/node/node-service/releases/2012-01-23T16-32-12.780436389" "--npat"
remote: npm ERR! cwd /home/node/node-service/releases/2012-01-23T16-32-12.780436389
remote: npm ERR! node -v v0.4.11
remote: npm ERR! npm -v 1.0.27
remote: npm ERR! 

Solution/Fix


To solve all issues I had to add the devDependencies of mongoose's package.json to the myapp package.json incl. mongoose dependency.

To make this all Joyent SmartMachine node-service ready you have to add

{ "start": "node app.js" }

to your package.json, otherwise node-service does not know which .js to execute as primary.

I will post my entire success story step by step this evening

2

There are 2 answers

0
alessioalex On BEST ANSWER

Since your error is remote: uncaught: Error: Cannot find module 'should' that means you forgot to include the should module as a dependency in package.json.

Ex:

 ...
 "dependencies" : {
   ...
   "should": "0.5.1"
 }
 ...

For more information on package.json checkout: http://package.json.nodejitsu.com/

0
pfleidi On

My solution to this problem: Create a symlink called server.js which links to your application:

ln -s app.js server.js
git commit server.js
git push node master