Node JS hooks with NVM-installed node

In my internal network I created a VM running Ubuntu 16.04, on which I installed my Node app and nginx in front of it as proxy. I’m trying to add Let’s Encrypt to nginx, but since it’s in a private network, I created these scripts to update the public facing DNS for the DNS challenge. Since it’s Node, I tried using shebangs and with the node command in front of the hooks arguments, but the node executable is never found.

Failed to find executable node in PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
pre-hook command node exists, but is not executable.

This is very weird. I installed node using NVM, which adds the following lines to ~/.bash_rc:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

So if I run which node, I get /home/mcdado/.nvm/versions/node/v6.11.2/bin/node. Also, this is my PATH variable.

$ echo $PATH | tr ':' '\n'
/home/mcdado/.nvm/versions/node/v6.11.2/bin
/home/mcdado/bin
/home/mcdado/.local/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin

My only thought is that the hook are run in a shell that doesn’t load .bash_rc, can you confirm that this is the case? I’d prefer not having to keep symlinks in /usr/local/bin to the specific node, since NVM can change the path when changing versions. Any suggestions on what to do?


Please fill out the fields below so we can help you better.

My domain is: (internal)

I ran this command: sudo certbot --nginx --preferred-challenges dns-01 --pre-hook 'node /home/mcdado/ovh-certbot-dns/bin/create-record.js' --post-hook 'node /home/mcdado/ovh-certbot-dns/bin/delete-record.js' (also tried without node leading the js path, since the js files are executables with shebangs, similar results: /usr/bin/env: ‘node’: No such file or directory)

It produced this output: Failed to find executable node in PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin pre-hook command node exists, but is not executable.'

My web server is (include version): nginx 1.10.3

The operating system my web server runs on is (include version): Ubuntu 16.04.3 Server

I can login to a root shell on my machine: yes (sudo)

I’m using a control panel to manage my site (no, or provide the name and version of the control panel): no

By the way, I figured out that I shouldn’t use --nginx and --pre-hook or --post-hook, but rather do certonly --manual and use --manual-auth-hook and --manual-cleanup-hook.

I decided to scrap the NVM route and install Node like indicated on the website:

https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.