Getting fatal error running node.js git hook

I’m running a git hook (pre-push) and getting a fatal error.

Here’s my code:

#!/usr/local/bin node

var exec = require('child_process').exec

process.exit(1)

Nothing crazy, just testing things out.

And it’s executable.

But when I run a push I get:

fatal: cannot exec '.git/hooks/pre-push': Permission denied

And the process hangs.

  • Install node module from own gitlab server
  • npm install error: Receiving Fork Errors: “died waiting for dll loading, errno 11”
  • No mouse control on three.js spline editor when combined with femgl in node.js
  • Heroku Cannot GET /
  • How to add a non-npm dependency to my package.json?
  • Use of git tags in package.json (for git dependencies)
  • Error when running 'npm install' for a package from a git repo
  • How to add /usr/local/bin in $PATH on Mac
  • One Solution collect form web for “Getting fatal error running node.js git hook”

    Try instead:

    #!/usr/local/bin/node
    

    Make sure the path /usr/local/bin/node does exist.

    Alternative (which might be what you actually wanted to do):

    #!/usr/bin/env node
    

    Again, make sure /usr/bin/env exists, and that /usr/bin/env node returns the expected path.

    Git Baby is a git and github fan, let's start git clone.