在Heroku上部署Node App引发与NodeMon相关的错误 [英] Deploying node app on heroku firing errors related to nodemon

查看:221
本文介绍了在Heroku上部署Node App引发与NodeMon相关的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在heroku中运行我的节点应用程序,但出现此错误,该错误与nodemon依赖性有关.

I am trying to run my node app in heroku but I am getting this error which is related to nodemon dependency.

2018-12-16T21:32:51.891208+00:00 app[web.1]: sh: 1: nodemon: not found
2018-12-16T21:32:51.895084+00:00 app[web.1]: npm ERR! file sh
2018-12-16T21:32:51.895380+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-12-16T21:32:51.895627+00:00 app[web.1]: npm ERR! errno ENOENT
2018-12-16T21:32:51.895865+00:00 app[web.1]: npm ERR! syscall spawn
2018-12-16T21:32:51.896987+00:00 app[web.1]: npm ERR! turktutor_backend@1.0.0 start: `nodemon --watch`
2018-12-16T21:32:51.897151+00:00 app[web.1]: npm ERR! spawn ENOENT

我有这样的package.json:

I have my package.json like that:

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon --watch"
  },
"dependencies": {
    "bcrypt": "^3.0.2",
    "body-parser": "^1.18.3",
    "express": "^4.16.4",
    "express-validator": "^5.3.0",
    "googleapis": "^27.0.0",
    "jsonwebtoken": "^8.4.0",
    "mongoose": "^5.3.14",
    "mongoose-unique-validator": "^2.0.2",
    "nodemailer": "^4.7.0"
  },
  "devDependencies": {
    "morgan": "^1.9.1",
    "nodemon": "^1.18.7"
  }

我尝试按照此

i tried to follow the solution in this link that requires changing "Procfile" file, but heroku says that Procfile is no longer required for Node.js apps source

我想知道是否需要通过一些命令将devDependencies安装在heroku服务器中!

I am wondering if I need to install my devDependencies in heroku server by some command!

所以请帮忙解决这个问题?

so please any help to solve this problem?

推荐答案

我发现heroku默认在生产环境中运行,因此它不安装dev依赖项,因此我在package.json中创建了两个不同的npm脚本脚本像这样:

i figured out that heroku runs in a production environment by default so it does not install the dev dependencies so i created two diffrent npm scripts script in my package.json like that:

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js",
    "start:dev": "nodemon --watch"
},

,当我想在本地运行项目时,我运行npm run start:dev,以便它通过nodemon加载index.js,而在heroku中npm start默认运行,并从普通的node命令加载index.js.

and when i want to run the project locally i run npm run start:dev so it load index.js by nodemon, while in heroku npm start runs by default and load index.js from a normal node command.

这篇关于在Heroku上部署Node App引发与NodeMon相关的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆