Fail to deploy node.js application to heroku

后端 未结 5 1575
感动是毒
感动是毒 2020-12-10 03:52

I am trying to deploy a simple node.js express-based application to heroku, something which is apparently very basic: https://devcenter.heroku.com/articles/nodejs

He

相关标签:
5条回答
  • 2020-12-10 04:31

    I got this fixed by:

    • Making sure Procfile is committed into git

    • Removing the node_modules/ folder and committing that into git (git rm -r node_modules/)

    Afterwards, I did the git push heroku master then the error disappeared.

    0 讨论(0)
  • 2020-12-10 04:35

    Heroku team, could you please consider configuring npm to use npm install --no-bin-links --production by default, or creating an environment variable to let users set that flag. This is a serious bug in node installs. Removing the bin directory from my .gitignore (as suggested below) enabled me to deploy, but it breaks using git effectively in a cross-platform development environment, requiring an explicit npm rebuild on every git pull where node_modules might have changed.

    NPM best practice is to avoid having node_modules in .gitignore (see http://www.futurealoof.com/posts/nodemodules-in-git.html ).

    I believe --no-bin-links will provide the best of both worlds, enabling deploys of node_modules where the bin directory has been excluded, supporting npm rebuild, but not failing when a bin link is created.

    I submitted a pull request here: https://github.com/heroku/heroku-buildpack-nodejs/pull/33

    Thanks!

    0 讨论(0)
  • 2020-12-10 04:38

    I had this problem, and it was because:

    1. I keep node_modules in version control
    2. I had bin in my .gitignore file

    npm was attempting to chmod express/bin/express, but due to my .gitignore this file wasn't in git and thus was not being cloned during the deploy, so it failed. I didn't notice it because a local npm install would create the bin/express file as usual.

    Removing bin from .gitignore and committing the missing files solved the problem for me.

    0 讨论(0)
  • 2020-12-10 04:44

    I had a similar problem a few days ago, I think it was because I imported a module created by me and that was what gave the error; I corrected it like this: I called the module "path" const path = require ("path") and then where my module was imported I made a join of the file path const myModule = require (path.join (__ dirname, 'MyModule.js'))

    0 讨论(0)
  • 2020-12-10 04:49

    similar issue was fixed by renaming gruntfile.js to Gruntfile.js

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