【问题标题】:heroku logs --tail error: sh: 1: nodemon: not foundheroku 日志 --tail 错误:sh:1:nodemon:未找到
【发布时间】:2021-11-25 23:26:01
【问题描述】:

我正在尝试通过 heroku cli 启动我的网络应用程序。部署后我尝试heroku open。当我这样做时,它会向我显示“应用程序失败”页面,他们会在其中为我提供运行命令 heroku logs --tail 的建议。 我看到很长的执行列表,其中崩溃的第一件事是找不到 nodemon

问题是,当我在本地 npm start 时,我可以成功运行 nodemon。当我打开heroku时会出现问题。

heroku logs --tail 结果如下:

2021-10-05T01:56:54.934519+00:00 app[web.1]: 
2021-10-05T01:56:54.938108+00:00 app[web.1]: sh: 1: nodemon: not found
2021-10-05T01:56:54.942920+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-10-05T01:56:54.943131+00:00 app[web.1]: npm ERR! syscall spawn
2021-10-05T01:56:54.943211+00:00 app[web.1]: npm ERR! file sh
2021-10-05T01:56:54.943308+00:00 app[web.1]: npm ERR! errno ENOENT
2021-10-05T01:56:54.948219+00:00 app[web.1]: npm ERR! detectfaceappapiv1@1.0.0 start: `nodemon server.js`
2021-10-05T01:56:54.948271+00:00 app[web.1]: npm ERR! spawn ENOENT
2021-10-05T01:56:54.948334+00:00 app[web.1]: npm ERR!
2021-10-05T01:56:54.948383+00:00 app[web.1]: npm ERR! Failed at the detectfaceappapiv1@1.0.0 start script.
2021-10-05T01:56:54.948435+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-10-05T01:56:54.962550+00:00 app[web.1]:
2021-10-05T01:56:54.962668+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-10-05T01:56:54.962697+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-10-05T01_56_54_949Z-debug.log
2021-10-05T01:56:55.104892+00:00 heroku[web.1]: Process exited with status 1
2021-10-05T01:56:55.183845+00:00 heroku[web.1]: State changed from starting to crashed
2021-10-05T03:15:45.740085+00:00 heroku[web.1]: State changed from crashed to starting
2021-10-05T03:15:47.727415+00:00 heroku[web.1]: Starting process with command `npm start`
2021-10-05T03:15:48.650607+00:00 app[web.1]:
2021-10-05T03:15:48.650704+00:00 app[web.1]: > detectfaceappapiv1@1.0.0 start /app
2021-10-05T03:15:48.650706+00:00 app[web.1]: > nodemon server.js
2021-10-05T03:15:48.650707+00:00 app[web.1]:
2021-10-05T03:15:48.662047+00:00 app[web.1]: sh: 1: nodemon: not found
2021-10-05T03:15:48.666240+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-10-05T03:15:48.666406+00:00 app[web.1]: npm ERR! syscall spawn
2021-10-05T03:15:48.666477+00:00 app[web.1]: npm ERR! file sh
2021-10-05T03:15:48.666556+00:00 app[web.1]: npm ERR! errno ENOENT
2021-10-05T03:15:48.668678+00:00 app[web.1]: npm ERR! detectfaceappapiv1@1.0.0 start: `nodemon server.js`
2021-10-05T03:15:48.668725+00:00 app[web.1]: npm ERR! spawn ENOENT
2021-10-05T03:15:48.668776+00:00 app[web.1]: npm ERR!
2021-10-05T03:15:48.668823+00:00 app[web.1]: npm ERR! Failed at the detectfaceappapiv1@1.0.0 start script.
2021-10-05T03:15:48.668863+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-10-05T03:15:48.672520+00:00 app[web.1]:
2021-10-05T03:15:48.672592+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-10-05T03:15:48.672626+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-10-05T03_15_48_669Z-debug.log
2021-10-05T03:15:48.789238+00:00 heroku[web.1]: Process exited with status 1
2021-10-05T03:15:48.830329+00:00 heroku[web.1]: State changed from starting to crashed
2021-10-05T04:54:45.976500+00:00 heroku[web.1]: State changed from crashed to starting
2021-10-05T04:54:48.314500+00:00 heroku[web.1]: Starting process with command `npm start`
2021-10-05T04:54:50.071787+00:00 app[web.1]:
2021-10-05T04:54:50.071800+00:00 app[web.1]: > detectfaceappapiv1@1.0.0 start /app
2021-10-05T04:54:50.071801+00:00 app[web.1]: > nodemon server.js
2021-10-05T04:54:50.071801+00:00 app[web.1]:
2021-10-05T04:54:50.079652+00:00 app[web.1]: sh: 1: nodemon: not found
2021-10-05T04:54:50.085454+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-10-05T04:54:50.085719+00:00 app[web.1]: npm ERR! syscall spawn
2021-10-05T04:54:50.085859+00:00 app[web.1]: npm ERR! file sh
2021-10-05T04:54:50.086080+00:00 app[web.1]: npm ERR! errno ENOENT
2021-10-05T04:54:50.090304+00:00 app[web.1]: npm ERR! detectfaceappapiv1@1.0.0 start: `nodemon server.js`
2021-10-05T04:54:50.090391+00:00 app[web.1]: npm ERR! spawn ENOENT
2021-10-05T04:54:50.090480+00:00 app[web.1]: npm ERR!
2021-10-05T04:54:50.090562+00:00 app[web.1]: npm ERR! Failed at the detectfaceappapiv1@1.0.0 start script.
2021-10-05T04:54:50.090951+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-10-05T04:54:50.098509+00:00 app[web.1]:
2021-10-05T04:54:50.098701+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-10-05T04:54:50.098774+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-10-05T04_54_50_092Z-debug.log
2021-10-05T04:54:50.259919+00:00 heroku[web.1]: Process exited with status 1
2021-10-05T04:54:50.632592+00:00 heroku[web.1]: State changed from starting to crashed
2021-10-05T09:12:32.734768+00:00 heroku[web.1]: State changed from crashed to starting
2021-10-05T09:12:35.155424+00:00 heroku[web.1]: Starting process with command `npm start`
2021-10-05T09:12:36.467495+00:00 app[web.1]:
2021-10-05T09:12:36.467505+00:00 app[web.1]: > detectfaceappapiv1@1.0.0 start /app
2021-10-05T09:12:36.467505+00:00 app[web.1]: > nodemon server.js
2021-10-05T09:12:36.467506+00:00 app[web.1]:
2021-10-05T09:12:36.477925+00:00 app[web.1]: sh: 1: nodemon: not found
2021-10-05T09:12:36.493189+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-10-05T09:12:36.493573+00:00 app[web.1]: npm ERR! syscall spawn
2021-10-05T09:12:36.493747+00:00 app[web.1]: npm ERR! file sh
2021-10-05T09:12:36.493936+00:00 app[web.1]: npm ERR! errno ENOENT
2021-10-05T09:12:36.497717+00:00 app[web.1]: npm ERR! detectfaceappapiv1@1.0.0 start: `nodemon server.js`
2021-10-05T09:12:36.498844+00:00 app[web.1]: npm ERR! spawn ENOENT
2021-10-05T09:12:36.498951+00:00 app[web.1]: npm ERR!
2021-10-05T09:12:36.499039+00:00 app[web.1]: npm ERR! Failed at the detectfaceappapiv1@1.0.0 start script.
2021-10-05T09:12:36.499117+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-10-05T09:12:36.506402+00:00 app[web.1]:
2021-10-05T09:12:36.506477+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-10-05T09:12:36.506548+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-10-05T09_12_36_500Z-debug.log
2021-10-05T09:12:36.659116+00:00 heroku[web.1]: Process exited with status 1
2021-10-05T09:12:36.751331+00:00 heroku[web.1]: State changed from starting to crashed
2021-10-05T14:43:53.915711+00:00 heroku[web.1]: State changed from crashed to starting
2021-10-05T14:43:56.228553+00:00 heroku[web.1]: Starting process with command `npm start`
2021-10-05T14:43:57.534046+00:00 app[web.1]:
2021-10-05T14:43:57.534087+00:00 app[web.1]: > detectfaceappapiv1@1.0.0 start /app
2021-10-05T14:43:57.534092+00:00 app[web.1]: > nodemon server.js
2021-10-05T14:43:57.534092+00:00 app[web.1]:
2021-10-05T14:43:57.549030+00:00 app[web.1]: sh: 1: nodemon: not found
2021-10-05T14:43:57.557412+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-10-05T14:43:57.557713+00:00 app[web.1]: npm ERR! syscall spawn
2021-10-05T14:43:57.557808+00:00 app[web.1]: npm ERR! file sh
2021-10-05T14:43:57.557992+00:00 app[web.1]: npm ERR! errno ENOENT
2021-10-05T14:43:57.561619+00:00 app[web.1]: npm ERR! detectfaceappapiv1@1.0.0 start: `nodemon server.js`
2021-10-05T14:43:57.561706+00:00 app[web.1]: npm ERR! spawn ENOENT
2021-10-05T14:43:57.561794+00:00 app[web.1]: npm ERR!
2021-10-05T14:43:57.561875+00:00 app[web.1]: npm ERR! Failed at the detectfaceappapiv1@1.0.0 start script.
2021-10-05T14:43:57.561942+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-10-05T14:43:57.570261+00:00 app[web.1]:
2021-10-05T14:43:57.570325+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-10-05T14:43:57.570363+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-10-05T14_43_57_563Z-debug.log
2021-10-05T14:43:57.714282+00:00 heroku[web.1]: Process exited with status 1
2021-10-05T14:43:57.777703+00:00 heroku[web.1]: State changed from starting to crashed

【问题讨论】:

标签: node.js heroku npm server nodemon


【解决方案1】:

尝试将您的 procfile 更改为 web: node myapp.js。也有可能 webpack 覆盖了你的 procfile。在这里查看问题和答案: Heroku failing to start my node app because its trying to do it with nodemon

【讨论】:

  • 感谢 Procfile 的想法。我的项目没有,所以我必须创建它。不幸的是,这还不足以解决我的问题。
【解决方案2】:

经过无休止的搜索,我找到了对我有用的补救措施!

我按照 youtube 视频中的说明进行操作: https://www.youtube.com/watch?v=xxua85cCiT0

  1. 创建过程文件
  2. 使 NPM_CONFIG_PRODUCTION=false 或将 nodemon 包从 devDependencies 移动到依赖项。
  3. 手动将端口更改为 8080

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-18
    • 1970-01-01
    • 1970-01-01
    • 2021-10-05
    • 2021-07-24
    • 2022-07-28
    • 2018-03-20
    • 2019-07-14
    相关资源
    最近更新 更多