I tried deploying Node.js API on Heroku, but shows Application Error.
So, used the "heroku local web" command to test any error..and got an error saying that 'babel-node' is not recognized as an internal or external command, operable program or batch file.
On the other hand, when I run the command 'npm start' I dont get any error and the server starts running.
package.json
{
"name": "apollo-starter-kit",
"version": "0.1.0",
"description": "Minimal set of code to write a GraphQL server with Apollo graphql-tools",
"scripts": {
"start": "nodemon ./server.js --exec babel-node",
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint ."
},
"repository": {
"type": "git",
"url": "git+https://github.com/apollostack/apollo-starter-kit.git"
},
"keywords": [
"Node.js",
"Javascript",
"GraphQL",
"Express",
"Apollo",
"Meteor"
],
"author": "Jonas Helfer <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/apollostack/apollo-starter-kit/issues"
},
"homepage": "https://github.com/apollostack/apollo-starter-kit#readme",
"dependencies": {
"apollo-server": "^0.1.2",
"casual": "^1.5.10",
"cors": "^2.8.1",
"express": "^4.13.4",
"lodash": "^4.17.4",
"mongoose": "^4.8.1",
"sequelize": "^3.30.2",
"sqlite": "^2.3.0"
},
"devDependencies": {
"babel-cli": "6.5.1",
"babel-core": "^6.5.2",
"babel-eslint": "^6.0.0-beta.6",
"babel-loader": "6.2.3",
"babel-plugin-inline-import": "^2.0.1",
"babel-polyfill": "6.5.0",
"babel-preset-es2015": "6.5.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "6.5.0",
"casual": "^1.5.10",
"eslint": "^2.4.0",
"eslint-config-airbnb": "^6.1.0",
"eslint-plugin-import": "^1.1.0",
"eslint-plugin-react": "^4.2.3",
"graphql": "^0.6.0",
"nodemon": "^1.9.1"
},
"peerDependencies": {
"graphql": "^0.5.0 || ^0.6.0"
},
"eslintConfig": {
"parser": "babel-eslint",
"extends": [
"airbnb/base",
"plugin:import/errors"
],
"rules": {
"no-use-before-define": 0,
"arrow-body-style": 0,
"dot-notation": 0,
"no-console": 0
},
"env": {
"mocha": true
}
}
}
I think the most likely cause is that babel
is part of dev dependencies and those are not installed by default via official node.js buildpack. Change NPM_CONFIG_PRODUCTION
to false
and it should work.
You can use command line
heroku config:set NPM_CONFIG_PRODUCTION=false
You can always login into Heroku dyno to check if everything is installed properly
heroku run bash
You should not be using babel-node in production. It is unnecessarily heavy, with high memory usage due to the cache being stored in memory. You will also always experience a startup performance penalty as the entire app needs to be compiled on the fly.
ref: https://medium.com/@Cuadraman/how-to-use-babel-for-production-5b95e7323c2f
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With