heroku logs --tail error: sh: 1: nodemon: not found



我正试图通过heroku cli启动我的web应用程序。部署后,我尝试heroku open。当我这样做时,它显示我"申请失败";页面,他们为我提供了运行命令heroku logs --tail的建议。我看到一个很长的执行列表,其中第一件崩溃的事情是未能找到nodemon

的事情是,我可以成功运行nodemon当我npm start本地。当我打开。

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

尝试将procfile更改为web: node myapp.js。也有可能webpack覆盖了你的配置文件。点击这里查看问题和答案:Heroku无法启动我的node应用程序,因为它试图使用nodemon

经过无休止的寻找,我找到了一个对我有效的补救方法!

我遵循了youtube视频中的说明:https://www.youtube.com/watch?v=xxua85cCiT0

  1. 创建Procfile
  2. 设置NPM_CONFIG_PRODUCTION=false或者将nodemon包从devDependencies移到dependencies。
  3. 手动更改端口为8080