在Heroku上执行Procfile模块之前,NodeJs应用程序在module.js中崩溃

时间:2013-04-27 19:51:41

标签: node.js heroku

我在Windows 7计算机上本地运行我的NodeJs应用程序,而0.8.18上没有任何问题。但是,当我将其推送到Heroku并尝试访问URL时,会记录以下错误:

2013-04-27T19:34:14.073833+00:00 heroku[web.1]: Process exited with status 1
2013-04-27T19:34:59.340168+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=myapp.org fwd="108.212.64.90" dyno= connect= service= status=503 bytes=
2013-04-27T19:35:00.565119+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=myapp.org fwd="108.212.64.90" dyno= connect= service= status=503 bytes=
2013-04-27T19:44:23.916316+00:00 heroku[web.1]: Starting process with command `node myApp.js`
2013-04-27T19:44:24.424716+00:00 app[web.1]:
2013-04-27T19:44:24.425324+00:00 app[web.1]: /app/myApp.js:7
2013-04-27T19:44:24.425680+00:00 app[web.1]:    ;
2013-04-27T19:44:24.425725+00:00 app[web.1]:    ^
2013-04-27T19:44:24.429639+00:00 app[web.1]: SyntaxError: Unexpected token ;
2013-04-27T19:44:24.429639+00:00 app[web.1]:     at Module._compile (module.js:437:25)
2013-04-27T19:44:24.429639+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:467:10)
2013-04-27T19:44:24.429639+00:00 app[web.1]:     at Module.load (module.js:356:32)
2013-04-27T19:44:24.429639+00:00 app[web.1]:     at Function.Module._load (module.js:312:12)
2013-04-27T19:44:24.429639+00:00 app[web.1]:     at Module.runMain (module.js:492:10)
2013-04-27T19:44:24.429639+00:00 app[web.1]:     at process.startup.processNextTick.process._tickCallback (node.js:245:9)
2013-04-27T19:44:25.437926+00:00 heroku[web.1]: Process exited with status 1
2013-04-27T19:44:25.414435+00:00 heroku[web.1]: State changed from starting to crashed
2013-04-27T19:44:22.954367+00:00 heroku[web.1]: State changed from crashed to starting

我的proc文件只是:

web: node myApp.js

我的package.json读取:

{
  "name": "Arbol",
  "version": "0.0.1",
  "dependencies": {
    "express": "3.1.0",
"bcrypt": "0.7.5",
"connect-flash": "0.1.0",
"sequelize":"1.4.1",
"ejs":"0.8.3",
"oath":"0.2.3",
"node-markdown":"0.1.1",
"pg":"0.15.1",
"passport":"0.1.16",
"passport-twitter":"0.1.4",
"passport-google":"0.3.0",
"passport-facebook":"0.1.5"
  },
  "engines": {
    "node": "0.8.x",
    "npm": "1.1.x"
  }
}

此外,以下是myApp.js的第一行:

console.log('neither here');
var express = require('express'),
app = module.exports = express(),
passport = require('passport'),
flash = require('connect-flash'),
FacebookStrategy = require('passport-facebook').Strategy,
TwitterStrategy = require('passport-twitter').Strategy,
GoogleStrategy = require('passport-google').Strategy;
console.log('nor there');

部署到Heroku时,不会记录任何console.log消息。

似乎myApp.js中没有任何内容导致此问题,而是由Module引起的。什么是Module.js?我在哪里可以找到它以及为什么我的应用会导致问题呢?

1 个答案:

答案 0 :(得分:1)

我改变了package.json来明确说明确切的节点版本,问题就消失了:

  "engines": {
     "node": "0.8.19",
   "npm": "1.1.x"
   }