I have an upstart script that runs a nodejs-app, but Node.js is installed with nvm. I source some variables to upstart from another file, and my script section looks like this:


. /etc/default/nodejs

exec start-stop-daemon --start  --make-pidfile --pidfile /var/run/app.pid
--chdir /home/node-apps/ --chuid root:root
--exec $NODE_NVM_PATH app.js >> /var/log/node/app.log 2>&1

end script

In /etc/default/nodejs (chmod 744) I have this:

NODE_NVM_PATH=$(which node)

with the idea that which node outputs the nodejs' path installed via nvm; because if I update or change the Node.js version, I don't want to edit the new path in this file.

But using this method, don't works and my app.js it is not running. I have also tried export NODE_NVM_PATH=$(which node), and the same result.

But if I put:


inside /etc/default/nodejs everything works perfectly.

So my question is:

How can I get the execution of a which node in this other file and source it to upstart?


  • I have also an enviromment variable called $NVM_BIN that outputs the nodejs'path, but don't know also how to source it to upstart.

  • The exec instructions in deed, are only in one line; I pasted here in separated lines to avoid scrolling

1 Answers

Gurdyal On

try backquotes " ` " instead of $( )

NODE_NVM_PATH=$(which node)

NODE_NVM_PATH=`which node`


you can let us know what it does.