简体   繁体   中英

CWD of an Node.js application started with upstart (Ubuntu)

I've coded an node.js app that when get executed need to return CWD from process to be able to read files on disk.

When I start the app directly with node in the actual app directory...

 #!sh
 node app.js

everything is working fine and "process.cwd()" return the good path. But when the script is started with upstart or even directly with node from an other directory "process.cwd()" return "/" in the case of upstart and whatever directory from witch I directly start my app with node. So process.cwd() seem to output the directory from witch the command is executed. Why? What to do?

Node.js提供了一个全局变量“__dirname”,它提供了应用程序的实际路径。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM