Node.js CWD application started upstart (Ubuntu)

I encoded a node.js application which, when executed, should return CWD from the process in order to read files on disk.

When I run the application directly from node in the actual applications directory ...

 #!sh
 node app.js

everything works fine, and "process.cwd ()" returns a good path. But when the script is launched with upstart or even directly with a node from another directory "process.cwd ()" return "/" in the case of an upstart and any directory from a witch, I directly launch my application using node. So process.cwd () seems to list the directory from the command line. What for? What to do?

+5
source share
1 answer

Node.js provides the global variable "__dirname", which provides the actual path of your application.

+7
source

All Articles