Search code examples
node.jsangularheroku

How to fix heroku build.sh permissin denied Error in Angular App


I am deploying my Angular application and getting this error:

sh: 1: ./heroku.build.sh: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! [email protected] heroku-postbuild: `./heroku.build.sh

package.json

    "heroku-postbuild": "./heroku.build.sh"

heroku.build.sh

#!/usr/bin/env bash

usage() {
  echo "OVERVIEW: Build apps according to BUILD_ENV value. Meant to be used for Heroku deployment"
  exit
}

if [ "$1" = '-h' ] || [ "$1" = '--help' ]; then
  usage
fi

(
  if [ "$BUILD_ENV" ]; then
    ng build $BUILD_ENV --configuration $ENVIRONMENT && ng run $BUILD_ENV:server:$ENVIRONMENT
  else
    echo "Error: no build config for BUILD_ENV value '$BUILD_ENV'"
    exit 1
  fi
)

How to fix this error?

I removed node_modules and deleted the heroku.build.sh but still it did not work.


Solution

  • For windows this will work

    In a terminal, I ran git add --chmod=+x heroku.build.sh Then git commit -m "Updated permission" Finally git push