nodemon:在 heroku 上找不到

nodemon: not found on heroku

我的应用程序在本地运行时没有问题,因为它在 Heroku 上失败了 package.json

{
  "name": "app name",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "start": "nodemon app.js"
  },
  "engines": {
    "node": "14.17.0"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.19.0",
    "express": "^4.17.1",
    "mongoose": "^5.12.9"
  }
}

过程文件

web:node app.js

它返回以下错误

sh: 1: nodemon: not found

关于如何完成这项工作的任何帮助?

nodemon 全局安装在您的机器上,这就是为什么您可以 运行 它在您的机器上。当你在 Heroku 上推送它时,它显示错误,因为没有像 nodemon.

这样的东西

此外,Heroku 不需要 nodemon 所以只需替换您的启动脚本:

node app.js

并将您的 Procfile 更改为:

web: npm start