Search code examples
node.jsupstart

node.js does not start via upstart (but does when manually run from command line)


I have a node.js app that I can run successfully from the command line. I'd like to run it using Upstart.

I'm seeing a [ReferenceError: requirejs is not defined] when it hits the first line of my app, which is...

var requirejs = require('requirejs');

The exec line from my upstart script looks like

exec sudo -u pi /usr/local/bin/node /home/[my_app_dir]/myapp.js >> /var/log/myapp.log 2>&1

PATH not being set correctly?


Solution

  • it's more likely it's looking in the wrong place for resolving node_modules. Do a cd (relevant dir) followed by node myapp >> ... instead, and it should be able to find all your required libraries.