unable to push node.js cloudant app to bluemix

2019-09-11 22:43发布

问题:

I tried to add cloudant to my app and all of a sudden I can't push it to bluemix anymore. I tracked it down to 1 line which caused the problem:

var cloudant = require('cloudant');

prior to this it uploaded with no problems. During the push everything seems fine until it reached the end when it tried to restart the droplet

-----> Uploading droplet (20M)
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 failing
FAILED
Start unsuccessful

I saw a post about using a later node engine "node": "0.12.x" but that did not work. I removed the node_module directory and did a npm install, to confirm that I can run this app locally and that the package.json is good.

$ cat manifest.yml
applications:
- path: .
  memory: 256M
  instances: 1
  domain: stage1.mybluemix.net
  name: myapp
  host: myapp
  disk_quota: 1024M
  command: node server.js
  services:
  - myNoSQLDB

$ cat package.json
{
  "name": "myapp",
  "version": "1.0.0",
  "description": "my test app",
  "private": true,
  "scripts": {
  "start": "node server.js"
  },
  "dependencies": {
    "angular": "1.4.x",
    "angular-route": "1.4.x",
    "body-parser": "^1.15.1",
    "bootstrap": "3.3.x",
    "cfenv": "1.0.x",
    "cloudant": "1.4.x",
    "depd": "^1.1.0",
    "console-stamp": "^0.2.2",
    "cookie-parser": "1.4.x",
    "express": "4.13.x",
    "express-session": "1.11.x",
    "fs": "0.0.x",
    "https": "1.0.x",
    "jquery": "2.2.x",
    "passport": "0.2.x"
  },
  "repository": {},
  "engines": {
    "node": "4.x"
  }
}

When this first happened, I took a look at the output from cf logs my app --recent and it showed

Error: Cannot find module 'depd'

which should of been installed as a dependency. So I added that to my package.json. Now it's coming up with a different missing module!!

Here is the output from cf logs myapp --recent:

2016-06-10T13:01:07.81-0400 [DEA/20]     OUT Starting app instance (index 0) with guid 28bae25d-5202-46d9-8d53-394711f2db0d
2016-06-10T13:01:18.53-0400 [App/0]      ERR module.js:327
2016-06-10T13:01:18.53-0400 [App/0]      ERR     throw err;
2016-06-10T13:01:18.53-0400 [App/0]      ERR     ^
2016-06-10T13:01:18.53-0400 [App/0]      ERR Error: Cannot find module 'content-type'
2016-06-10T13:01:18.53-0400 [App/0]      ERR     at Function.Module._resolveFilename (module.js:325:15)
2016-06-10T13:01:18.53-0400 [App/0]      ERR     at Function.Module._load (module.js:276:25)
2016-06-10T13:01:18.53-0400 [App/0]      ERR     at Module.require (module.js:353:17)
2016-06-10T13:01:18.53-0400 [App/0]      ERR     at require (internal/module.js:12:17)
2016-06-10T13:01:18.53-0400 [App/0]      ERR     at Object.<anonymous> (/home/vcap/app/node_modules/body-parser/lib/types/urlencoded.js:16:19)
2016-06-10T13:01:18.53-0400 [App/0]      ERR     at Module._compile (module.js:409:26)
2016-06-10T13:01:18.53-0400 [App/0]      ERR     at Object.Module._extensions..js (module.js:416:10)
2016-06-10T13:01:18.53-0400 [App/0]      ERR     at Module.load (module.js:343:32)
2016-06-10T13:01:18.53-0400 [App/0]      ERR     at Function.Module._load (module.js:300:12)
2016-06-10T13:01:18.53-0400 [App/0]      ERR     at Module.require (module.js:353:17)
2016-06-10T13:01:18.53-0400 [App/0]      ERR     at require (internal/module.js:12:17)
2016-06-10T13:01:18.53-0400 [App/0]      OUT
2016-06-10T13:01:18.62-0400 [DEA/20]     ERR Instance (index 0) failed to start accepting connections
2016-06-10T13:01:18.66-0400 [API/1]      OUT App instance exited with guid 28bae25d-5202-46d9-8d53-394711f2db0d payload: {"cc_partition"=>"default", "droplet"=>"28bae25d-5202-46d9-8d53-394711f2db0d", "version"=>"7a0c73de-69cc-48d6-9d70-2397d56a6174", "instance"=>"62e1200500034fa5a7e41ffa0ae2715d", "index"=>0, "reason"=>"CRASHED", "exit_status"=>1, "exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>1465578078}
2016-06-10T13:01:18.66-0400 [API/1]      OUT App instance exited with guid 28bae25d-5202-46d9-8d53-394711f2db0d payload: {"cc_partition"=>"default", "droplet"=>"28bae25d-5202-46d9-8d53-394711f2db0d", "version"=>"7a0c73de-69cc-48d6-9d70-2397d56a6174", "instance"=>"62e1200500034fa5a7e41ffa0ae2715d", "index"=>0, "reason"=>"CRASHED", "exit_status"=>1, "exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>1465578078}

I saw a post about this and the fix was to remove node_module dir and reinstall, but this should be the default when pushing to bluemix, all modules gets reinstalled.

Is this something specific with bluemix and cloudant? I've pushed apps to bluemix before with no problems, what am I missing?

Both of these modules seem to be from the express dependency. Why is it not being installed by bluemix?

I do have a .cfignore file but was listing all the sub dir under node_module cause at the time bluemix indicated that the module passport-idaas-openidconnect had to be downloaded from their site cause there was an issue with npm for that module.