Node.js Heroku Deployment - Fails To Exec Postinstall Script To Install Bower

后端 未结 5 828
暗喜
暗喜 2021-01-31 22:47

Deployment of my Node.js MEAN app to heroku fails with the following errors. I can\'t figure out what is wrong with the bower install...

Here is the error message:

5条回答
  •  深忆病人
    2021-01-31 23:24

    This is likely related to this issue with bower, the cause of which is currently still being investigated:

    https://github.com/bower/bower/issues/933

    I've also been having some similar issues with the bower install command failing on heroku. Here's what worked for me:

    1. Temporarily remove node_modules and bower_components from .gitignore.

    • This seemed to fix an ENOENT error when trying to install Angular using bower through a postinstall script in heroku.
    • Note: If you specify a different installation directory for bower components in your .bowerrc file, then make sure that directory is not present in your .gitignore.

    2. Edit (or create) .bowerrc and tell it to use temp directories that are local to the project directory:

    {
        "storage": {
            "packages": ".bower-cache",
            "registry": ".bower-registry"
        },
        "tmp": ".bower-tmp"
    }
    
    • By default, bower was trying to use a directory in /app, which was resulting in ENOTEMPTY errors (maybe because it was trying to clear those directories, but it didn't have access because they are shared with other users? Just throwing out a guess...)
    • Using a directory that's local to the project fixed the conflicts.

    Hope this helps someone else.

    Note: Even after performing the above steps, the bower install command may still occasionally fail. However, it generally works the second or third time - just try running the command again... Until the underlying issue is resolved, that's the best advice that I can offer.

提交回复
热议问题