【问题标题】:Heroku deployment error crashing appHeroku 部署错误导致应用程序崩溃
【发布时间】:2017-08-22 01:47:46
【问题描述】:

我正在尝试将带有 node.js 的 Angular 应用程序部署到 Heroku,但我不断收到这些错误。我检查了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 文件似乎也存在问题。并且请忽略条带相关的错误,谢谢

【问题讨论】:

  • 我建议您从 git 中删除 .env 文件,而不是将其部署到 Heroku。
  • 好的,我现在试试,谢谢
  • 您可能想发布您的 package.json,因为这里似乎存在多个问题。
  • 我删除了 .env 文件,我收到了同样的错误。错误 H10
  • 怎么说“请忽略与 Stripe 相关的错误”。一些代码期望能够加载一个名为 Stripe 的模块,但它找不到它导致上述错误。

标签: angularjs node.js debugging heroku


【解决方案1】:

您似乎缺少名为 stripe 的 Node 模块。如果您已将其包含在您的devDependencies 中,Heroku 不会安装它们。您必须将其移动到 dependencies 属性才能在您的应用程序中正确使用。您还应该从您的 GitHub 存储库中删除 .env 文件,正如 toddg 在他的回答中所描述的那样。

【讨论】:

  • 但这就是导致它无法启动的原因。您的.env 文件(或缺少)不会导致应用程序无法启动(我的也是如此); Node 模块是阻止它部署的原因。
  • 没有删除条纹,我在发布问题后立即删除了它
【解决方案2】:

从你的 git repo 中删除你的 .env。

创建 .gitignore 文件

从命令行:touch .gitignore

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

.env

由于 .env 已被跟踪,您需要将其从跟踪中移除:

git rm --cached .env

然后提交并重新部署到 Heroku

【讨论】:

  • 我的 git repo 上没有 .env 文件
  • 您需要发布您的 package.json 以便我们为您提供帮助。这里有很多问题。
  • 我修复了错误,该应用程序现在已托管,但这里有人知道为什么登录功能在移动设备上不起作用,我正在使用 Jason Web 令牌进行身份验证,Web 令牌的行为是否不同移动浏览器?
【解决方案3】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-22
    • 1970-01-01
    • 2019-12-05
    • 2020-08-09
    • 2020-08-25
    • 2020-09-24
    • 1970-01-01
    • 2017-07-01
    相关资源
    最近更新 更多