Heroku部署错误崩溃应用程序

时间:2017-03-28 20:01:52

标签: angularjs node.js debugging heroku

我正在尝试使用node.js在backoku中部署一个角度应用程序,我不断收到这些错误。我检查了heroku日志,并返回了此错误。

$ heroku logs

2017-03-28T19:39:19.558737+00:00 app[web.1]:     at Function.Module._load (module.js:417:25)
2017-03-28T19:39:19.558740+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:579:10)
2017-03-28T19:39:19.558738+00:00 app[web.1]:     at Module.require (module.js:497:17)
2017-03-28T19:39:19.558740+00:00 app[web.1]:     at Module._compile (module.js:570:32)
2017-03-28T19:39:19.558741+00:00 app[web.1]:     at Module.load (module.js:487:32)
2017-03-28T19:39:19.558741+00:00 app[web.1]:     at tryModuleLoad (module.js:446:12)
2017-03-28T19:39:19.558742+00:00 app[web.1]:     at Function.Module._load (module.js:438:3)
2017-03-28T19:39:19.558744+00:00 app[web.1]:     at Module._compile (module.js:570:32)
2017-03-28T19:39:19.558743+00:00 app[web.1]:     at Module.require (module.js:497:17)
2017-03-28T19:39:19.558745+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:579:10)
2017-03-28T19:39:19.558743+00:00 app[web.1]:     at require (internal/module.js:20:19)
2017-03-28T19:39:19.568956+00:00 app[web.1]: 
2017-03-28T19:39:19.558744+00:00 app[web.1]:     at Object.<anonymous> (/app/bin/www:7:11)
2017-03-28T19:39:19.558746+00:00 app[web.1]:     at Module.load (module.js:487:32)
2017-03-28T19:39:19.576891+00:00 app[web.1]: npm ERR! Linux 3.13.0-112-generic
2017-03-28T19:39:19.577955+00:00 app[web.1]: npm ERR! Exit status 1
2017-03-28T19:39:19.578118+00:00 app[web.1]: npm ERR! 
2017-03-28T19:39:19.577095+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2017-03-28T19:39:19.578397+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2017-03-28T19:39:19.577245+00:00 app[web.1]: npm ERR! node v6.10.1
2017-03-28T19:39:19.577457+00:00 app[web.1]: npm ERR! npm  v3.10.10
2017-03-28T19:39:19.577660+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-03-28T19:39:19.577817+00:00 app[web.1]: npm ERR! swiping@0.0.0 start: `node bin/www`
2017-03-28T19:39:19.578260+00:00 app[web.1]: npm ERR! Failed at the swiping@0.0.0 start script 'node bin/www'.
2017-03-28T19:39:19.580186+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-03-28T19:39:19.578536+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the swiping package,
2017-03-28T19:39:19.578674+00:00 app[web.1]: npm ERR! not with npm itself.
2017-03-28T19:39:19.579513+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-03-28T19:39:19.579652+00:00 app[web.1]: npm ERR!     node bin/www
2017-03-28T19:39:19.580319+00:00 app[web.1]: npm ERR!     npm owner ls swiping
2017-03-28T19:39:19.579787+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-03-28T19:39:19.580044+00:00 app[web.1]: npm ERR!     npm bugs swiping
2017-03-28T19:39:19.584013+00:00 app[web.1]: 
2017-03-28T19:39:19.580460+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-03-28T19:39:19.584213+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-03-28T19:39:19.584307+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2017-03-28T19:39:19.665671+00:00 heroku[web.1]: Process exited with status 1
2017-03-28T19:39:19.683203+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-28T19:50:32.379502+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-28T19:50:36.835295+00:00 heroku[web.1]: Starting process with command `npm start`
2017-03-28T19:50:40.588438+00:00 app[web.1]: > swiping@0.0.0 start /app
2017-03-28T19:50:40.588424+00:00 app[web.1]: 
2017-03-28T19:50:40.588439+00:00 app[web.1]: > node bin/www
2017-03-28T19:50:40.588439+00:00 app[web.1]: 
2017-03-28T19:50:40.884038+00:00 app[web.1]: { Error: ENOENT: no such file or directory, open '.env'
2017-03-28T19:50:40.884053+00:00 app[web.1]:     at Error (native)
2017-03-28T19:50:40.884054+00:00 app[web.1]:     at Object.fs.openSync (fs.js:641:18)
2017-03-28T19:50:40.884055+00:00 app[web.1]:     at Object.fs.readFileSync (fs.js:509:33)
2017-03-28T19:50:40.884056+00:00 app[web.1]:     at Object.config (/app/node_modules/dotenv/lib/main.js:30:37)
2017-03-28T19:50:40.884056+00:00 app[web.1]:     at Object.<anonymous> (/app/server.js:7:19)
2017-03-28T19:50:40.884057+00:00 app[web.1]:     at Module._compile (module.js:570:32)
2017-03-28T19:50:40.884057+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:579:10)
2017-03-28T19:50:40.884058+00:00 app[web.1]:     at Module.load (module.js:487:32)
2017-03-28T19:50:40.884058+00:00 app[web.1]:     at tryModuleLoad (module.js:446:12)
2017-03-28T19:50:40.884060+00:00 app[web.1]:     at Function.Module._load (module.js:438:3) errno: -2, code: 'ENOENT', syscall: 'open', path: '.env' }
2017-03-28T19:50:41.499429+00:00 app[web.1]: module.js:471
2017-03-28T19:50:41.499443+00:00 app[web.1]:     throw err;
2017-03-28T19:50:41.499444+00:00 app[web.1]:     ^
2017-03-28T19:50:41.499445+00:00 app[web.1]: 
2017-03-28T19:50:41.499446+00:00 app[web.1]: Error: Cannot find module 'stripe'
2017-03-28T19:50:41.499447+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:469:15)
2017-03-28T19:50:41.499448+00:00 app[web.1]:     at Function.Module._load (module.js:417:25)
2017-03-28T19:50:41.499450+00:00 app[web.1]:     at Module._compile (module.js:570:32)
2017-03-28T19:50:41.499450+00:00 app[web.1]:     at Object.<anonymous> (/app/server.js:23:31)
2017-03-28T19:50:41.499452+00:00 app[web.1]:     at Module.load (module.js:487:32)
2017-03-28T19:50:41.499449+00:00 app[web.1]:     at require (internal/module.js:20:19)
2017-03-28T19:50:41.499448+00:00 app[web.1]:     at Module.require (module.js:497:17)
2017-03-28T19:50:41.499451+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:579:10)
2017-03-28T19:50:41.499453+00:00 app[web.1]:     at tryModuleLoad (module.js:446:12)
2017-03-28T19:50:41.499453+00:00 app[web.1]:     at Function.Module._load (module.js:438:3)
2017-03-28T19:50:41.499454+00:00 app[web.1]:     at Module.require (module.js:497:17)
2017-03-28T19:50:41.499454+00:00 app[web.1]:     at require (internal/module.js:20:19)
2017-03-28T19:50:41.499455+00:00 app[web.1]:     at Object.<anonymous> (/app/bin/www:7:11)
2017-03-28T19:50:41.499456+00:00 app[web.1]:     at Module._compile (module.js:570:32)
2017-03-28T19:50:41.499456+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:579:10)
2017-03-28T19:50:41.499457+00:00 app[web.1]:     at Module.load (module.js:487:32)
2017-03-28T19:50:41.518990+00:00 app[web.1]: 
2017-03-28T19:50:41.533527+00:00 app[web.1]: npm ERR! Linux 3.13.0-112-generic
2017-03-28T19:50:41.533975+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2017-03-28T19:50:41.534366+00:00 app[web.1]: npm ERR! node v6.10.1
2017-03-28T19:50:41.534659+00:00 app[web.1]: npm ERR! npm  v3.10.10
2017-03-28T19:50:41.534971+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-03-28T19:50:41.535416+00:00 app[web.1]: npm ERR! Exit status 1
2017-03-28T19:50:41.535202+00:00 app[web.1]: npm ERR! swiping@0.0.0 start: `node bin/www`
2017-03-28T19:50:41.536538+00:00 app[web.1]: npm ERR! 
2017-03-28T19:50:41.536786+00:00 app[web.1]: npm ERR! Failed at the swiping@0.0.0 start script 'node bin/www'.
2017-03-28T19:50:41.537264+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the swiping package,
2017-03-28T19:50:41.537011+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2017-03-28T19:50:41.538192+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-03-28T19:50:41.537489+00:00 app[web.1]: npm ERR! not with npm itself.
2017-03-28T19:50:41.538418+00:00 app[web.1]: npm ERR!     node bin/www
2017-03-28T19:50:41.538660+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-03-28T19:50:41.538885+00:00 app[web.1]: npm ERR!     npm bugs swiping
2017-03-28T19:50:41.539142+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-03-28T19:50:41.539657+00:00 app[web.1]: npm ERR!     npm owner ls swiping
2017-03-28T19:50:41.539883+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-03-28T19:50:41.545636+00:00 app[web.1]: 
2017-03-28T19:50:41.545943+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-03-28T19:50:41.546128+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2017-03-28T19:50:41.644752+00:00 heroku[web.1]: Process exited with status 1
2017-03-28T19:50:41.660900+00:00 heroku[web.1]: State changed from starting to crashed

任何建议,我调整了package.json以启动节点bin / www,因为这是我在本地主机上启动应用程序的方式。看到.env文件似乎也有问题。请忽略与条纹相关的错误,谢谢

3 个答案:

答案 0 :(得分:1)

您似乎错过了名为stripe的Node模块。如果您已将其包含在devDependencies中,则Heroku不会安装它们。您必须将其移至dependencies属性才能在您的应用中正确使用。你也应该从你的GitHub仓库中删除.env文件,正如toddg在他的回答中所描述的那样。

答案 1 :(得分:0)

从您的git repo中删除.env。

创建.gitignore文件

从命令行:touch .gitignore

打开刚刚创建的文件(使用vi或您喜欢的文本编辑器)并添加以下行:

.env

由于已经跟踪了.env,因此您需要将其从跟踪中删除:

git rm --cached .env

然后提交并重新部署到Heroku

答案 2 :(得分:0)

已解决的问题。删除所有使用localhost的package.json,将目录更改为您自己的app.js或您的js根文件名。给吴建。上载到herokuapp。