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

后端 未结 3 643
没有蜡笔的小新
没有蜡笔的小新 2021-02-04 04:13

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 ca

相关标签:
3条回答
  • 2021-02-04 04:38

    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
    
    0 讨论(0)
  • 2021-02-04 04:40

    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.

    0 讨论(0)
  • 2021-02-04 04:41

    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

    0 讨论(0)
提交回复
热议问题