0

error:sh: 1: nodemon: not found

packages:

{
  "name": "shorturlproxy",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "nodemon index.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "keywords": [],
  "description": "",
  "devDependencies": {
    "nodemon": "^2.0.15"
  }

Do you know what I do wrong?

Mediator
  • 14,951
  • 35
  • 113
  • 191
  • Heroku strips development dependencies after the build (read [the docs](https://devcenter.heroku.com/articles/nodejs-support#package-installation)). Why use nodemon in production anyway? – jonrsharpe Jan 24 '22 at 19:18
  • I'm out of comment upvotes for the day, but jonrsharpe is correct: you shouldn't be using `nodemon` on Heroku in the first place. If you need to build your code (e.g. to compile TypeScript or minify CSS or build a production Vue.js release or something), add a build script that does that and then just use `node` in your start script. If you want to use `nodemon` for local development call it something else. A dev script is common for this. – ChrisGPT was on strike Jan 24 '22 at 19:48
  • Does this answer your question? [Heroku failing to start my node app because its trying to do it with nodemon](https://stackoverflow.com/questions/22618930/heroku-failing-to-start-my-node-app-because-its-trying-to-do-it-with-nodemon) – ChrisGPT was on strike Jan 24 '22 at 19:50

1 Answers1

0

The simple way is call the (local) "nodemon" with relative path, so replace the "start" value:

"scripts": {
  "start": "./node_modules/.bin/nodemon index.js",
  "test": "echo \"Error: no test specified\" && exit 1"
},

Also there is a way to install it globally (npm i -g nodemon) before running the server, but I'm not sure this will work on Heroku

boolfalse
  • 1,892
  • 2
  • 13
  • 14