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

两盒软妹~` 提交于 2019-12-03 05:24:50
Ricardo Souza

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!