【发布时间】: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