Reputation: 339
I have a node app, perfectly running on the localhost. but after deploying it to Heroku it crashes.
Here's the Error Log:
2019-11-07T10:58:20.359983+00:00 heroku[web.1]: Starting process with
command `npm start`
2019-11-07T10:58:22.882837+00:00 heroku[web.1]: State changed from starting to crashed
2019-11-07T10:58:22.866125+00:00 heroku[web.1]: Process exited with status 1
2019-11-07T10:58:22.768738+00:00 app[web.1]:
2019-11-07T10:58:22.768765+00:00 app[web.1]: > [email protected] start /app
2019-11-07T10:58:22.768768+00:00 app[web.1]: > nodemon --exec babel-node server.js --plugins css-modules-transform --ignore dist/
2019-11-07T10:58:22.768770+00:00 app[web.1]:
2019-11-07T10:58:22.783839+00:00 app[web.1]: sh: 1: nodemon: not found
2019-11-07T10:58:22.788270+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-11-07T10:58:22.788822+00:00 app[web.1]: npm ERR! syscall spawn
2019-11-07T10:58:22.789278+00:00 app[web.1]: npm ERR! file sh
2019-11-07T10:58:22.789688+00:00 app[web.1]: npm ERR! errno ENOENT
2019-11-07T10:58:22.791368+00:00 app[web.1]: npm ERR! [email protected] start: `nodemon --exec babel-node server.js --plugins css-modules-transform --ignore dist/`
2019-11-07T10:58:22.791637+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-11-07T10:58:22.791917+00:00 app[web.1]: npm ERR!
2019-11-07T10:58:22.792199+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2019-11-07T10:58:22.792534+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-11-07T10:58:22.802491+00:00 app[web.1]:
2019-11-07T10:58:22.802775+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-11-07T10:58:22.802918+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-11-07T10_58_22_793Z-debug.log
I am not sure about the cause but it looks like it can't find nodemon, Maybe it's unable to install all the dependencies. as mentioned in the error message;
Here's my Procfile:
web: npm start
and Here's my package.json
{
"name": "dpapi",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon --exec babel-node server.js --plugins css-modules-transform --ignore dist/",
"dev": "webpack -wd"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.4.4",
"babel-eslint": "^10.0.1",
"babel-preset-es2015": "^6.24.1",
"eslint": "^5.16.0",
"eslint-plugin-react": "^7.13.0",
"nodemon": "^1.18.11",
"webpack-cli": "^3.3.1"
},
"dependencies": {
"@babel/core": "^7.4.4",
"@babel/node": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-proposal-export-default-from": "^7.2.0",
"@babel/preset-env": "^7.4.4",
"@babel/preset-react": "^7.0.0",
"@material-ui/core": "^4.0.0-rc.0",
"@material-ui/icons": "^3.0.2",
"axios": "^0.18.0",
"babel-loader": "^8.0.5",
"bcrypt": "^3.0.6",
"body-parser": "^1.19.0",
"buffer": "^5.2.1",
"dropbox": "^4.0.17",
"ejs": "^2.6.1",
"express": "^4.16.4",
"global": "^4.4.0",
"imagemagick": "^0.1.3",
"isomorphic-fetch": "^2.2.1",
"js-file-download": "^0.4.7",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.5.7",
"morgan": "^1.9.1",
"multer": "^1.4.1",
"node-fetch": "^2.5.0",
"nodemailer": "^6.2.1",
"query-string": "^6.5.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-redux": "^7.0.3",
"react-router-dom": "^5.0.0",
"react-stripe-elements": "^3.0.0",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"rimraf": "^2.6.3",
"socket.io": "^2.2.0",
"socket.io-client": "^2.2.0",
"stripe": "^7.4.0",
"webpack": "^4.30.0"
}
}
Upvotes: 0
Views: 218
Reputation: 1135
Heroku deployment fails because it cannot find nodemon
in your dependencies
. The easy solution would probably be to move it in there.
The more accurate answer, your current configuration is perfect for development but not for production.
I would advise to first compile your code with webpack (or whatever you currently use), deploy the build code and use the regular node server.js
as your npm start
script.
Heroku will take care of restarting your application in case of a failure, you don't need nodemon.
Upvotes: 2