2016-05-02 12 views
0

Ich verwende Bluemix, um eine Beispielanwendung node.js zu implementieren. Alles funktioniert gut, wenn ich kein Q Paket in meinem App-Code benötige. Aber die App-Bereitstellung schlägt fehl, wenn ich das Q-Paket in meinem Code benötige.Die Bereitstellung der Bluemix node.js-App schlägt fehl, wenn das Q-Knotenmodul verwendet wird

Hier ist meine 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); 
}); 

Allerdings, wenn ich die Protokolle überprüfen Q Modul tatsächlich installiert ist und wie unten zeigt.

├── [email protected] 

Bluemix Einsatz logs -

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! [email protected] 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 [email protected] 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 

HINWEIS: Wenn ich die Zeile Q = require('Q') funktioniert alles einwandfrei entfernen und App wird im Einsatz und wurde erfolgreich gestartet. Auch ich habe es lokal auf meiner Maschine getestet und es funktioniert einwandfrei.

Irgendwelche Vorschläge oder Lösungen? Vielen Dank!

+0

Wie funktioniert das lokal, wenn Sie 'Q' anstelle von' q' benötigen? – Seth

+0

@Seeth, es funktioniert irgendwie lokal in meiner Maschine und wirft keinen Fehler über das Knotenmodul, das nicht gefunden wird. Das ist wirklich seltsam. Ich verstehe nicht, warum dieser Fehler nicht lokal ausgelöst wird. Und interessant ist, es funktioniert in beiden Fällen klein oder caps 'q'. –

Antwort

2

Versuchen Sie, den folgenden Code:

var Q = require('q'); 

Der q Modulname ist q, nicht Q.

+0

Danke für die Korrektur mit dem Gehäuse. Ich muss wissen, dass osx und windows nicht die Groß-/Kleinschreibung beachten und daher keinen Fehler verursachen, aber auf Linux basiert env. –

1

Der Schlüssel zu Ihrem Problem dieser Fehler ist:

Error: Cannot find module 'Q'

Der Name des Moduls ist nicht Q, ist es q. Ändern Sie diesen Wert und es wird Ihr Problem beheben.