nodemon start errors on Heroku - node.js

I've been running into the same start error when I deploy onto Heroku. I know it has something to do with my start script but I can't seem to pin down the issue.
I'm running into this error on app start:
2018-10-22T15:31:04.927032+00:00 heroku[web.1]: Process exited with status 1
2018-10-22T15:31:04.944756+00:00 heroku[web.1]: State changed from starting to crashed
2018-10-22T15:31:04.946982+00:00 heroku[web.1]: State changed from crashed to starting
2018-10-22T15:31:04.804183+00:00 app[web.1]:
2018-10-22T15:31:04.804198+00:00 app[web.1]: > Backend# start /app
2018-10-22T15:31:04.804200+00:00 app[web.1]: > nodemon -e js,graphql -x node -r dotenv/config src/index.js
2018-10-22T15:31:04.804202+00:00 app[web.1]:
2018-10-22T15:31:04.810881+00:00 app[web.1]: sh: 1: nodemon: not found
2018-10-22T15:31:04.817652+00:00 app[web.1]: npm ERR! file sh
2018-10-22T15:31:04.818091+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-10-22T15:31:04.818534+00:00 app[web.1]: npm ERR! errno ENOENT
2018-10-22T15:31:04.818822+00:00 app[web.1]: npm ERR! syscall spawn
2018-10-22T15:31:04.820778+00:00 app[web.1]: npm ERR! Backend# start: `nodemon -e js,graphql -x node -r dotenv/config src/index.js`
2018-10-22T15:31:04.821033+00:00 app[web.1]: npm ERR! spawn ENOENT
2018-10-22T15:31:04.821320+00:00 app[web.1]: npm ERR!
2018-10-22T15:31:04.821464+00:00 app[web.1]: npm ERR! Failed at the Backend# start script.
2018-10-22T15:31:04.821628+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-10-22T15:31:04.829156+00:00 app[web.1]:
2018-10-22T15:31:04.829411+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-10-22T15:31:04.829659+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-10-22T15_31_04_823Z-debug.log
2018-10-22T15:31:09.008630+00:00 heroku[web.1]: Starting process with command `npm start`
2018-10-22T15:31:12.142111+00:00 app[web.1]:
2018-10-22T15:31:12.142136+00:00 app[web.1]: > Backend# start /app
2018-10-22T15:31:12.142138+00:00 app[web.1]: > nodemon -e js,graphql -x node -r dotenv/config src/index.js
2018-10-22T15:31:12.142140+00:00 app[web.1]:
2018-10-22T15:31:12.151638+00:00 app[web.1]: sh: 1: nodemon: not found
2018-10-22T15:31:12.157445+00:00 app[web.1]: npm ERR! file sh
2018-10-22T15:31:12.157635+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-10-22T15:31:12.157787+00:00 app[web.1]: npm ERR! errno ENOENT
2018-10-22T15:31:12.157931+00:00 app[web.1]: npm ERR! syscall spawn
2018-10-22T15:31:12.159057+00:00 app[web.1]: npm ERR! Backend# start: `nodemon -e js,graphql -x node -r dotenv/config src/index.js`
2018-10-22T15:31:12.159155+00:00 app[web.1]: npm ERR! spawn ENOENT
2018-10-22T15:31:12.159323+00:00 app[web.1]: npm ERR!
2018-10-22T15:31:12.159423+00:00 app[web.1]: npm ERR! Failed at the Backend# start script.
2018-10-22T15:31:12.159520+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-10-22T15:31:12.164017+00:00 app[web.1]:
So it can't find nodemon, despite it being installed. Here's my package.json:
{
"name": "Backend",
"scripts": {
"start": "nodemon -e js,graphql -x node -r dotenv/config src/index.js",
"debug": "nodemon -e js,graphql -x node --inspect -r dotenv/config src/index.js",
"playground": "graphql playground",
"dev": "npm-run-all --parallel start playground"
},
"dependencies": {
"bcryptjs": "2.4.3",
"googleapis": "^27.0.0",
"graphql-yoga": "1.12.0",
"jsonwebtoken": "8.2.1",
"multer": "^1.4.0",
"node-schedule": "^1.3.0",
"nodemailer": "^4.6.4",
"prisma-binding": "1.5.17",
"winston": "^2.4.2",
"nodemon": "1.17.3"
},
"devDependencies": {
"dotenv": "5.0.1",
"graphql-cli": "2.15.9",
"nodemon": "1.17.3",
"npm-run-all": "4.1.2",
"prisma": "^1.6.3"
}
}
and my procfile is web: node src/index.js
Any help would be much appreciated, thanks.

It looks like nodemon -e js,graphql -x node -r dotenv/config src/index.js is being called by something other than npm, which is causing the issue with nodemon being missing, regardless of whether or not nodemon is actually present.
Here are some things you can do to isolate the root cause of the issue:
Confirm that the app works locally, with and without nodemon.
Ensure that your Procfile starts with a capitalized P (https://devcenter.heroku.com/articles/procfile#procfile-format)
Update the web directive in your profile to npm start
If the above changes don't work, run through the following:
Navigate to the root directory of your project, and start a remote session as follows: heroku ps:exec.
Once inside your app's dyno, run npm ls. If this fails, your dependencies haven't been installed properly (which looks like a Heroku issue)
If the above command succeeds, run npm start to confirm that the app can launch.

Related

How to solve the Error in deploying react app on Heroku

I run yarn install and yarn start locally for my project and it works fine. However, as soon as I push it to Heroku, I am unable to deploy it with the following error log:
2021-05-10T16:40:06.622555+00:00 app[web.1]: > react-scripts start
2021-05-10T16:40:06.622556+00:00 app[web.1]:
2021-05-10T16:40:06.627252+00:00 app[web.1]: sh: 1: react-scripts: not found
2021-05-10T16:40:06.636894+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-05-10T16:40:06.637303+00:00 app[web.1]: npm ERR! syscall spawn
2021-05-10T16:40:06.637496+00:00 app[web.1]: npm ERR! file sh
2021-05-10T16:40:06.637766+00:00 app[web.1]: npm ERR! errno ENOENT
2021-05-10T16:40:06.644457+00:00 app[web.1]: npm ERR! bleh#0.1.0 start: `react-scripts start`
2021-05-10T16:40:06.644627+00:00 app[web.1]: npm ERR! spawn ENOENT
2021-05-10T16:40:06.644771+00:00 app[web.1]: npm ERR!
2021-05-10T16:40:06.644922+00:00 app[web.1]: npm ERR! Failed at the bleh#0.1.0 start script.
2021-05-10T16:40:06.645043+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-05-10T16:40:06.654910+00:00 app[web.1]:
2021-05-10T16:40:06.655128+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-05-10T16:40:06.655306+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-05-10T16_40_06_646Z-debug.log
2021-05-10T16:40:06.706089+00:00 heroku[web.1]: Process exited with status 1
2021-05-10T16:40:06.778374+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-10T16:41:26.103511+00:00 app[api]: Deploy 1f4ec645 by user holliu9999#gmail.com
2021-05-10T16:41:26.103511+00:00 app[api]: Release v7 created by user holliu9999#gmail.com
2021-05-10T16:41:26.390448+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-10T16:41:30.000000+00:00 app[api]: Build succeeded
2021-05-10T16:41:32.398941+00:00 heroku[web.1]: Starting process with command `npm start`
In addition, I do only contain the yarn.lock in my directory so I am confused why it still runing npm. And here is my package.json file:
{
"name": "bleh",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-scripts": "0.9.0"
},
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-fontawesome": "^1.6.1",
"react-infinite": "^0.11.2",
"react-infinite-loader": "^1.0.2",
"react-router": "^3.0.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
You need to have a back-end server like node with express and config the script npm start. Go to Package.json --> scripts --> and add the script --> "start": "node app or index" depend of your root file. Btw you need to put the react application on the public folder of your backend.
Heroku needs a backend to start correctly.
You can see the express setup https://www.npmjs.com/package/express or http://expressjs.com/en/starter/hello-world.html

"index.js not found" when running npm start, ERR! code ELIFECYCLE and ENOENT

I'm trying to run a Discord bot via Heroku (will this work or is the whole idea flawed?)
However, I receive npm error codes every time I run npm start, and the bot remains offline on Discord.
I have already tried npm cache clean --force,
rmdir /S /Q node_modules and npm install, but none of these worked.
Here are the console logs:
2021-05-09T11:37:13.225562+00:00 heroku[web.1]: Process exited with status 1
2021-05-09T11:37:13.398582+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-09T11:37:20.322275+00:00 app[api]: Starting process with command `npm start` by user <email redacted>
2021-05-09T11:37:23.274907+00:00 heroku[run.4911]: State changed from starting to up
2021-05-09T11:37:23.427148+00:00 heroku[run.4911]: Awaiting client
2021-05-09T11:37:23.726119+00:00 heroku[run.4911]: Starting process with command `npm start`
2021-05-09T11:37:28.678579+00:00 heroku[run.4911]: Process exited with status 1
2021-05-09T11:37:28.742179+00:00 heroku[run.4911]: State changed from up to complete
2021-05-09T11:44:03.004685+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-09T11:44:05.335454+00:00 heroku[web.1]: Starting process with command `npm start`
2021-05-09T11:44:08.088534+00:00 heroku[web.1]: Process exited with status 1
2021-05-09T11:44:08.229000+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-09T11:44:08.232296+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-09T11:44:08.000901+00:00 app[web.1]:
2021-05-09T11:44:08.000925+00:00 app[web.1]: > CalculatorBot#1.0.0 start /app
2021-05-09T11:44:08.000925+00:00 app[web.1]: > index.js
2021-05-09T11:44:08.000925+00:00 app[web.1]:
2021-05-09T11:44:08.005333+00:00 app[web.1]: sh: 1: index.js: not found
2021-05-09T11:44:08.012134+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-05-09T11:44:08.012381+00:00 app[web.1]: npm ERR! syscall spawn
2021-05-09T11:44:08.012474+00:00 app[web.1]: npm ERR! file sh
2021-05-09T11:44:08.012618+00:00 app[web.1]: npm ERR! errno ENOENT
2021-05-09T11:44:08.016105+00:00 app[web.1]: npm ERR! CalculatorBot#1.0.0 start: `index.js`
2021-05-09T11:44:08.016163+00:00 app[web.1]: npm ERR! spawn ENOENT
2021-05-09T11:44:08.016238+00:00 app[web.1]: npm ERR!
2021-05-09T11:44:08.016285+00:00 app[web.1]: npm ERR! Failed at the CalculatorBot#1.0.0 start script.
2021-05-09T11:44:08.016364+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-05-09T11:44:08.024564+00:00 app[web.1]:
2021-05-09T11:44:08.024647+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-05-09T11:44:08.024701+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-05-09T11_44_08_016Z-debug.log
2021-05-09T11:44:11.422108+00:00 heroku[web.1]: Starting process with command `npm start`
2021-05-09T11:44:14.301131+00:00 heroku[web.1]: Process exited with status 1
2021-05-09T11:44:14.438297+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-09T11:44:14.212635+00:00 app[web.1]:
2021-05-09T11:44:14.212651+00:00 app[web.1]: > CalculatorBot#1.0.0 start /app
2021-05-09T11:44:14.212652+00:00 app[web.1]: > index.js
2021-05-09T11:44:14.212652+00:00 app[web.1]:
2021-05-09T11:44:14.217415+00:00 app[web.1]: sh: 1: index.js: not found
2021-05-09T11:44:14.225315+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-05-09T11:44:14.225593+00:00 app[web.1]: npm ERR! syscall spawn
2021-05-09T11:44:14.225710+00:00 app[web.1]: npm ERR! file sh
2021-05-09T11:44:14.225853+00:00 app[web.1]: npm ERR! errno ENOENT
2021-05-09T11:44:14.229827+00:00 app[web.1]: npm ERR! CalculatorBot#1.0.0 start: `index.js`
2021-05-09T11:44:14.229941+00:00 app[web.1]: npm ERR! spawn ENOENT
2021-05-09T11:44:14.230071+00:00 app[web.1]: npm ERR!
2021-05-09T11:44:14.230234+00:00 app[web.1]: npm ERR! Failed at the CalculatorBot#1.0.0 start script.
2021-05-09T11:44:14.230359+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-05-09T11:44:14.237148+00:00 app[web.1]:
2021-05-09T11:44:14.237336+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-05-09T11:44:14.237482+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-05-09T11_44_14_231Z-debug.log
And my package.json:
{
"name": "CalculatorBot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^12.5.3",
"math": "0.0.3"
}
}
Any ideas what I need to do to fix this, or if it is possible to run a Discord bot on Heroku?
change your package.json to the following
......
"start": "node index.js"
.......
Inside your Procfile put this line code same as I had listed here
web: node index.js
Now try again to deploy your WebApp with Heroku.

Heroku failing node app - try to run nodemon instead of node

I'm deploying my node app to Heroku and it's trying to invoke it with nodemon rather than the node app.js I have defined. my package.json(partial) looks like:
"scripts": {
"start": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"engines": {
"node": "7.9.0"
},
when I run heroku logs I get
2018-02-22T22:41:44.798831+00:00 heroku[web.1]: Starting process with command `npm start`
2018-02-22T22:41:47.235623+00:00 app[web.1]:
2018-02-22T22:41:47.235654+00:00 app[web.1]: > api-barber-app#1.0.0 start /app
2018-02-22T22:41:47.235657+00:00 app[web.1]: > nodemon app.js
2018-02-22T22:41:47.235659+00:00 app[web.1]:
2018-02-22T22:41:47.247464+00:00 app[web.1]: sh: 1: nodemon: not found
2018-02-22T22:41:47.253052+00:00 app[web.1]: npm ERR! file sh
2018-02-22T22:41:47.253319+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-02-22T22:41:47.253543+00:00 app[web.1]: npm ERR! errno ENOENT
2018-02-22T22:41:47.253787+00:00 app[web.1]: npm ERR! syscall spawn
2018-02-22T22:41:47.254995+00:00 app[web.1]: npm ERR! api-barber-app#1.0.0 start: `nodemon app.js`
2018-02-22T22:41:47.255145+00:00 app[web.1]: npm ERR! spawn ENOENT
2018-02-22T22:41:47.255420+00:00 app[web.1]: npm ERR!
2018-02-22T22:41:47.255617+00:00 app[web.1]: npm ERR! Failed at the api-barber-app#1.0.0 start script.
2018-02-22T22:41:47.255793+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-02-22T22:41:47.269400+00:00 app[web.1]:
2018-02-22T22:41:47.269715+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-02-22T22:41:47.269916+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-02-22T22_41_47_261Z-debug.log
2018-02-22T22:41:47.348415+00:00 heroku[web.1]: Process exited with status 1
2018-02-22T22:41:47.467170+00:00 heroku[web.1]: State changed from starting to crashed
2018-02-22T22:41:47.475956+00:00 heroku[web.1]: State changed from crashed to starting
2018-02-22T22:41:51.465439+00:00 heroku[web.1]: Starting process with command `npm start`
2018-02-22T22:41:54.918389+00:00 heroku[web.1]: Process exited with status 1
2018-02-22T22:41:54.679566+00:00 app[web.1]:
2018-02-22T22:41:54.679592+00:00 app[web.1]: > api-barber-app#1.0.0 start /app
2018-02-22T22:41:54.679594+00:00 app[web.1]: > nodemon app.js
2018-02-22T22:41:54.679596+00:00 app[web.1]:
2018-02-22T22:41:54.711632+00:00 app[web.1]: sh: 1: nodemon: not found
2018-02-22T22:41:54.759423+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-02-22T22:41:54.757722+00:00 app[web.1]: npm ERR! file sh
2018-02-22T22:41:54.761226+00:00 app[web.1]: npm ERR! syscall spawn
2018-02-22T22:41:54.760427+00:00 app[web.1]: npm ERR! errno ENOENT
2018-02-22T22:41:54.768513+00:00 app[web.1]: npm ERR! api-barber-app#1.0.0 start: `nodemon app.js`
2018-02-22T22:41:54.768637+00:00 app[web.1]: npm ERR! spawn ENOENT
2018-02-22T22:41:54.768942+00:00 app[web.1]: npm ERR!
2018-02-22T22:41:54.769147+00:00 app[web.1]: npm ERR! Failed at the api-barber-app#1.0.0 start script.
2018-02-22T22:41:54.769369+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-02-22T22:41:54.825892+00:00 app[web.1]:
2018-02-22T22:41:54.826567+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-02-22T22:41:54.827196+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-02-22T22_41_54_816Z-debug.log
2018-02-22T22:41:54.934234+00:00 heroku[web.1]: State changed from starting to crashed
it try to run nodemon (what I had before) instead of node.js.
then when I push heroku it crash and not let me upload it right way.
heroku runs in a production environment by default so it does not install the dev dependencies, you can create a two npm script to avoid this error by running nodemon only in your localhost like that:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js",
"start:dev": "nodemon --watch"
},
and when you want to run the project locally just run in your terminal npm run start:dev and it will load app.js by nodemon.
while in heroku npm start runs by default and load app.js from a normal node command and you get rid of that error.
I just had the same problem. After wasting a lot of time, I discovered that the whole time I was deploying the wrong branch. So if you are writing 'git push heroku master' for instance, 'master' is the branch you are pushing even if you are currently on a different branch.
Looks like nodemon is not in the dependencies, can you provide the package.json, make sure nodemon is in your dependencies

babel-node is not getting installed on Heroku

I'm using babel-node for ES6 syntax on Heroku, but I get a build error when I deploy. It says "babel-node: not found". I've tried a clean install on my local computer and it works perfectly. Package.json:
{
"name": "secret",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "./node_modules/.bin/babel-node ./bin/www"
},
"engines": {
"node": "7.5.0",
"npm": "5.0.3"
},
"dependencies": {
"babel-cli": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
...
}
}
I appreciate your help! :)
2017-07-17T11:02:26.997876+00:00 heroku[web.1]: State changed from crashed to starting
2017-07-17T11:02:31.839278+00:00 heroku[web.1]: Starting process with command `npm start`
2017-07-17T11:02:38.074157+00:00 heroku[web.1]: State changed from starting to crashed
2017-07-17T11:02:38.062607+00:00 heroku[web.1]: Process exited with status 1
2017-07-17T11:02:37.865774+00:00 app[web.1]:
2017-07-17T11:02:37.865786+00:00 app[web.1]: > secret#0.0.0 start /app
2017-07-17T11:02:37.865787+00:00 app[web.1]: > babel-node ./bin/www
2017-07-17T11:02:37.865787+00:00 app[web.1]:
2017-07-17T11:02:37.936361+00:00 app[web.1]: sh: 1: babel-node: not found
2017-07-17T11:02:37.966452+00:00 app[web.1]: npm ERR! file sh
2017-07-17T11:02:37.966683+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-07-17T11:02:37.966931+00:00 app[web.1]: npm ERR! errno ENOENT
2017-07-17T11:02:37.967106+00:00 app[web.1]: npm ERR! syscall spawn
2017-07-17T11:02:37.967287+00:00 app[web.1]: npm ERR! secret#0.0.0 start: `babel-node ./bin/www`
2017-07-17T11:02:37.967430+00:00 app[web.1]: npm ERR! spawn ENOENT
2017-07-17T11:02:37.967588+00:00 app[web.1]: npm ERR!
2017-07-17T11:02:37.967733+00:00 app[web.1]: npm ERR! Failed at the secret#0.0.0 start script.
2017-07-17T11:02:37.967873+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2017-07-17T11:02:37.969151+00:00 app[web.1]:
2017-07-17T11:02:37.969374+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-07-17T11:02:37.969484+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2017-07-17T11_02_37_957Z-debug.log
2017-07-17T11:25:52.044791+00:00 heroku[web.1]: State changed from crashed to starting
2017-07-17T11:25:54.841341+00:00 heroku[web.1]: Starting process with command `npm start`
2017-07-17T11:25:57.407691+00:00 heroku[web.1]: Process exited with status 1
2017-07-17T11:25:57.413873+00:00 heroku[web.1]: State changed from starting to crashed
2017-07-17T11:25:57.310176+00:00 app[web.1]:
2017-07-17T11:25:57.310190+00:00 app[web.1]: > secret#0.0.0 start /app
2017-07-17T11:25:57.310191+00:00 app[web.1]: > babel-node ./bin/www
2017-07-17T11:25:57.310192+00:00 app[web.1]:
2017-07-17T11:25:57.316940+00:00 app[web.1]: sh: 1: babel-node: not found
2017-07-17T11:25:57.335019+00:00 app[web.1]: npm ERR! file sh
2017-07-17T11:25:57.335287+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-07-17T11:25:57.335517+00:00 app[web.1]: npm ERR! errno ENOENT
2017-07-17T11:25:57.335735+00:00 app[web.1]: npm ERR! syscall spawn
2017-07-17T11:25:57.335933+00:00 app[web.1]: npm ERR! secret#0.0.0 start: `babel-node ./bin/www`
2017-07-17T11:25:57.336095+00:00 app[web.1]: npm ERR! spawn ENOENT
2017-07-17T11:25:57.336280+00:00 app[web.1]: npm ERR!
2017-07-17T11:25:57.336449+00:00 app[web.1]: npm ERR! Failed at the secret#0.0.0 start script.
2017-07-17T11:25:57.336614+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2017-07-17T11:25:57.337985+00:00 app[web.1]:
2017-07-17T11:25:57.338232+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-07-17T11:25:57.338379+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2017-07-17T11_25_57_323Z-debug.log
babel-node is "not meant for production use". There is a more relevant guide here for using #babel/cli, #babel/core and #babel/preset-env.
The babel dependencies should all be installed as devDependencies and you should transpile your code during in a build script run before Heroku prunes the devDependencies. See this guide
If you move all of your es6 code into a common directory like src at the top level of your app, you can create a build script to transpile everything in that directory to an output directory like build.
"build": "npm run clean && npm run build-babel",
"build-babel": "./node_modules/.bin/babel -d ./build ./src",
"clean": "rm -rf build && mkdir build",
In the example above, the build script will be run automatically by Heroku. clean will create a new build directory, and build-babel will transpile the code and place it in the build directory. After this is completed, Heroku will prune the devDependencies, but you will no longer need Babel.
When Heroku calls start below, it will be running your transpiled code. You should no longer see sh: 1: babel-node: not found.
"scripts": {
"build": "npm run clean && npm run build-babel",
"build-babel": "./node_modules/.bin/babel -d ./build ./src",
"clean": "rm -rf build && mkdir build",
"start": "node ./build/bin/www"
},
One potential gotcha, Do not call build from your start script. If you do, the devDependencies will have been pruned and you will get the following
sh: 1: babel: not found
A little bit late, but here is what I think you are missing:
Step (1): npm install --save babel-cli babel-preset-env in terminal
Note on step 1: Do not save to dev as that will require you to set NPM_CONFIG_PRODUCTION=false
Step (2): You are not compiling anything to babel without adding in the babel boilerplate and or using a babelrc file. Easiest method is to make a .babelrc file in your main app folder, ie. same one your package.json is in and input the following:
{
"presets": ["env"]
}
Note on step 2: With the usage of the env preset you do not need the babel-preset-es2015, etc
Step (3): You can now run your code using babel-node, so in your case execute your start script, ie. ./node_modules/.bin/babel-node ./bin/www
I suggest reading through the NPM module if you need further guidance understanding the preset logic: https://www.npmjs.com/package/babel-preset-env
Furthermore, I would suggest using a process manager like pm2. This allows your node instance to keep alive if it crashes. The forever module used to do this but pm2 is way better. Here is an example of a start script inside your package.json:
"scripts": {
"start": "node ./node_modules/.bin/pm2 start main.json --attach --env production"
}
Procfile (note, I am using nginx but just npm start would work fine):
web: bin/start-nginx npm start
worker: node ./node_modules/.bin/pm2 start worker.json --attach
And here would be your main.json with args to use babel-node (note, keep instance to 1 and do not fork on a web dyno in Heroku):
main.json:
{
"name": "the_awesome",
"script": "app.js",
"instances": 1,
"exec_mode": "cluster"
}
worker.json:
{
"name": "worker",
"script": "/app/lib/worker.js"
}
(4) Add a require('babel-register') hook to your app.js and worker.js if you are using pm2 in cluster mode. If you are using pm2 not in cluster mode, or just not using pm2 then you can use babel-node directly to run your .js or es6 files
Finally, to check if babel-node is really installed you can do the following:
heroku run bash -a {name of your app}
ls ./node_modules/.bin //babel-node should be present
Good luck!

package.json start script, babel-node: not found on heroku deploy

When I run heroku local or when I just do npm start locally, my app builds and runs fine. However when I deploy to heroku, the app crashes saying it cannot find babel-node.
Here is the log output:
2016-04-21T22:20:44.320025+00:00 heroku[api]: Deploy 5d9a9da by eagsalazar#gmail.com
2016-04-21T22:20:44.320084+00:00 heroku[api]: Release v9 created by eagsalazar#gmail.com
2016-04-21T22:20:44.542062+00:00 heroku[slug-compiler]: Slug compilation started
2016-04-21T22:20:44.542069+00:00 heroku[slug-compiler]: Slug compilation finished
2016-04-21T22:20:44.501025+00:00 heroku[web.1]: State changed from crashed to starting
2016-04-21T22:20:46.278065+00:00 heroku[web.1]: Starting process with command `npm start`
2016-04-21T22:20:50.467407+00:00 app[web.1]:
2016-04-21T22:20:50.467434+00:00 app[web.1]: > qc-server#1.0.0 start /app
2016-04-21T22:20:50.467435+00:00 app[web.1]: > babel-node index.js
2016-04-21T22:20:50.467436+00:00 app[web.1]:
2016-04-21T22:20:50.479490+00:00 app[web.1]: sh: 1: babel-node: not found
2016-04-21T22:20:50.521936+00:00 app[web.1]:
2016-04-21T22:20:50.538822+00:00 app[web.1]: npm ERR! Linux 3.13.0-79-generic
2016-04-21T22:20:50.539334+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-04-21T22:20:50.539595+00:00 app[web.1]: npm ERR! node v5.10.1
2016-04-21T22:20:50.555119+00:00 app[web.1]: npm ERR! npm v3.8.3
2016-04-21T22:20:50.555339+00:00 app[web.1]: npm ERR! file sh
2016-04-21T22:20:50.555549+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2016-04-21T22:20:50.555769+00:00 app[web.1]: npm ERR! errno ENOENT
2016-04-21T22:20:50.555965+00:00 app[web.1]: npm ERR! syscall spawn
2016-04-21T22:20:50.556142+00:00 app[web.1]: npm ERR! qc-server#1.0.0 start: `babel-node index.js`
2016-04-21T22:20:50.556305+00:00 app[web.1]: npm ERR! spawn ENOENT
2016-04-21T22:20:50.556488+00:00 app[web.1]: npm ERR!
2016-04-21T22:20:50.556666+00:00 app[web.1]: npm ERR! Failed at the qc-server#1.0.0 start script 'babel-node index.js'.
2016-04-21T22:20:50.556854+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2016-04-21T22:20:50.557017+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the qc-server package,
2016-04-21T22:20:50.557175+00:00 app[web.1]: npm ERR! not with npm itself.
2016-04-21T22:20:50.557343+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2016-04-21T22:20:50.557564+00:00 app[web.1]: npm ERR! babel-node index.js
2016-04-21T22:20:50.557741+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2016-04-21T22:20:50.557916+00:00 app[web.1]: npm ERR! npm bugs qc-server
2016-04-21T22:20:50.558110+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2016-04-21T22:20:50.558306+00:00 app[web.1]: npm ERR! npm owner ls qc-server
2016-04-21T22:20:50.558492+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2016-04-21T22:20:50.563859+00:00 app[web.1]:
2016-04-21T22:20:50.567790+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-04-21T22:20:50.568004+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2016-04-21T22:20:51.824822+00:00 heroku[web.1]: State changed from starting to crashed
2016-04-21T22:20:51.808246+00:00 heroku[web.1]: Process exited with status 1
My package.json:
{
"name": "qc-server",
"version": "1.0.0",
"description": "xxxx",
"main": "index.js",
"scripts": {
"test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js 'test/**/*.js'",
"test:watch": "npm run test -- --watch -G",
"start": "babel-node index.js"
},
"babel": {
"presets": [
"es2015"
]
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.6.0",
"babel-core": "^6.6.0",
"babel-eslint": "^5.0.0",
"babel-preset-es2015": "^6.6.0",
"chai": "^3.5.0",
"chai-immutable": "^1.5.3",
"eslint": "^2.2.0",
"eslint-config-airbnb": "^6.0.2",
"eslint-plugin-react": "^4.1.0",
"mocha": "^2.4.5"
},
"dependencies": {
"express": "^4.13.4",
"immutable": "^3.7.6",
"node-uuid": "^1.4.7",
"redux": "^3.3.1",
"socket.io": "^1.4.5"
}
}
Anyone have suggestions?
You have to include the dependency in you package.json so it will install it when you deploy.
$ npm install babel-cli -S
Than you have to change you start command to be like:
"start": "babel-node index.js"
See here for more info on deploying babel on heroku.com.
Warning: using babel-node is not recommended in production
I got the same issue, but I think set NPM_CONFIG_PRODUCTION=false to install devDependencies will be better. I used below command:
heroku config:set NPM_CONFIG_PRODUCTION=false
Specifically, include the necessary dependency under 'dependencies' and not 'devDependencies' in your 'package.json file'. This is because Heroku prunes (removes) your 'devDependencies' once it completes its build process, leaving only the 'dependencies', to keep the app as lean as possible.
This causes errors if you've built your NodeJS app using ES6 modules and included the necessary dependencies under 'devDependencies' instead of 'dependencies', namely the '#babel/' family of dependencies.
Update
You should always build your NodeJS App before you deploy it so that you are always running the production build in the live environment which executes much faster with fewer resources.

Resources