简体   繁体   English

使用Q节点模块时,Bluemix node.js应用程序部署失败

[英]Bluemix node.js app deployment fails when using Q node module

I am using Bluemix to deploy a sample node.js app. 我正在使用Bluemix部署示例node.js应用程序。 Everything works fine if i don't require Q package inside my app code. 如果我在我的应用程序代码中不需要Q包,则一切正常。 But the app deployment fails if i require the Q package inside my code. 但是,如果我在代码中需要Q包,则应用程序部署失败。

Here's my app code - 这是我的应用代码-

/*eslint-env node*/
var express = require('express'),
    cfenv = require('cfenv'),
    //bodyParser = require('body-parser'),
    //multer = require('multer'),
    Q = require('Q');
var app = express();
app.set('view engine', 'pug');
app.use(express.static(__dirname + '/views'));
app.get('/', function (req, res) {
    res.render('index');
});
app.listen(appEnv.port, '0.0.0.0', function() {
  console.log("server starting on " + appEnv.url);
});

However, when i check the logs Q module is indeed installed and shows as below. 但是,当我检查日志时, Q模块确实已安装并显示如下。

├── q@1.4.1

Bluemix deployment logs - Bluemix部署日志-

2016-05-03T00:30:05.46+0530 [App/0]      ERR module.js:328
2016-05-03T00:30:05.46+0530 [App/0]      ERR     throw err;
2016-05-03T00:30:05.46+0530 [App/0]      ERR     ^
2016-05-03T00:30:05.46+0530 [App/0]      ERR Error: Cannot find module 'Q'
2016-05-03T00:30:05.46+0530 [App/0]      ERR     at Function.Module._resolveFilename (module.js:326:15)
2016-05-03T00:30:05.46+0530 [App/0]      ERR     at Function.Module._load (module.js:277:25)
2016-05-03T00:30:05.46+0530 [App/0]      ERR     at Module.require (module.js:354:17)
2016-05-03T00:30:05.46+0530 [App/0]      ERR     at require (internal/module.js:12:17)
2016-05-03T00:30:05.46+0530 [App/0]      ERR     at Object.<anonymous> (/home/vcap/app/app.js:6:9)
2016-05-03T00:30:05.46+0530 [App/0]      ERR     at Module._compile (module.js:410:26)
2016-05-03T00:30:05.46+0530 [App/0]      ERR     at Object.Module._extensions..js (module.js:417:10)
2016-05-03T00:30:05.46+0530 [App/0]      ERR     at Module.load (module.js:344:32)
2016-05-03T00:30:05.46+0530 [App/0]      ERR     at Function.Module._load (module.js:301:12)
2016-05-03T00:30:05.46+0530 [App/0]      ERR     at Function.Module.runMain (module.js:442:10)
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR! Linux 3.19.0-25-generic
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR! argv "/home/vcap/app/vendor/node/bin/node" "/home/vcap/app/vendor/node/bin/npm" "start"
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR! node v4.2.6
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR! npm  v2.14.12
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR! code ELIFECYCLE
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR! SampleNodeApp@0.0.1 start: `node app.js`
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR! Exit status 1
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR! 
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR! Failed at the SampleNodeApp@0.0.1 start script 'node app.js'.
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR! This is most likely a problem with the SampleNodeApp package,
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR! not with npm itself.
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR! Tell the author that this fails on your system:
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR!     node app.js
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR! You can get their info via:
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR!     npm owner ls SampleNodeApp
2016-05-03T00:30:05.48+0530 [App/0]      ERR npm ERR! There is likely additional logging output above.
2016-05-03T00:30:05.49+0530 [App/0]      ERR npm ERR! Please include the following file with any support request:
2016-05-03T00:30:05.49+0530 [App/0]      ERR npm ERR!     /home/vcap/app/npm-debug.log
2016-05-03T00:30:05.56+0530 [DEA/137]    ERR Instance (index 0) failed to start accepting connections

NOTE: If i remove the line Q = require('Q') everything works fine and app gets deployed and started successfully. 注意:如果我删除行Q = require('Q')一切工作正常,应用程序已部署并成功启动。 Also i have tested it locally on my machine and it works perfectly fine. 另外,我已经在我的机器上本地测试过,并且效果很好。

Any suggestions or solutions? 有什么建议或解决方案吗? Thanks! 谢谢!

Try the following code: 尝试以下代码:

var Q = require('q');

The q module name is q , not Q . q模块名称是q ,而不是Q

The key to your problem is this error: 问题的关键是此错误:

Error: Cannot find module 'Q'

The name of the module is not Q , it is q . 模块的名称不是Q ,而是q Change that value and it will fix your issue. 更改该值,它将解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM