5

I have an idea of what the problem is, but I don't know how to fix it. My issue is that when I run the script post-receive, I get the error env: node: No such file or directory.

I think it may be because its a non-interactive shell and that I should change the $PATH, but I don't understand enough to know what I need to do. When I source the file, npm works without any issues. It only occurs when I call the script elsewhere remotely.

I'm using homebrew, nodev8, and postgres. I also have nvm managing node.

Here is my script:

#!/usr/bin/env bash . $NVM_DIR/nvm.sh echo 'post-receive: Triggered.' cd /Users/david/Development/abba/live/404 echo 'post-receive: git check out...' git --git-dir=/Users/david/Development/abba/404.git --work-tree=/Users/david/Development/abba/live/404 checkout master -f /Users/david/.nvm/v8.15.0/bin/npm install && echo 'post-receive: -> done.' 

Environment:

which node # /Users/david/.nvm/v8.15.0/bin/node echo $PATH # /Users/david/.nvm/v8.15.0/bin:/usr/local/opt/node@8/bin:/usr/local/opt/node@8/bin:/usr/local/opt/node@8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/node@8/bin:/usr/local/opt/node@8/bin 

.bash_profile:

export PATH="/usr/local/opt/node@8/bin:" export NVM_DIR="/Users/david/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm 
3
  • 1
    I'm currently facing the exact same problem. Did you get it solved? Commented Jan 16, 2020 at 20:11
  • @acb1980 no, I don't think so.. its been a while, since i last looked at it. I'll take a stab at it again soon though. Any progress on your end? Commented Jan 24, 2020 at 21:23
  • No, unfortunately not. It seems not to be possible to use node on a systems that generates this error. I've changed my workflow now so that I call node on another machine in the build process. Not the perfect solution, but it works for me. Commented Jan 25, 2020 at 10:07

1 Answer 1

3

I came across this same issue when trying to have a git post-receive hook trigger a build step. In my case, I solved the issue by symlinking the node binary into the /usr/bin/folder

ln -s `which node` /usr/bin/node 

I found a github issue which had a similar error here: https://github.com/animetosho/Nyuu/issues/14.

In that issue they used ln -s /usr/bin/nodejs /usr/bin/node

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.