1

I have a node.js application, and the folder structure is like below.

/root
    /libs
    /jobs
        /workers
    app.js

Upon launching, app.js will kick off a serial of scripts in /jobs folder in child processes. In turn, each job script may kick off more worker scripts in /workers folder again in child processes.

As all scripts in may reference scripts in /libs folder, I'm trying to avoid a relative path reference like

var libscript = require('../../libs/libscript'); 

I have viewed a few solution proposed online such as

These articles are fantastic but all are considering the problem within the same process. Do anyone have faced similar situation like mine and have some possible solutions?

The issue here is how to find the very parent's working directory from any child process or even grand-child process.

I'm running this in windows.

Thanks.

Community
  • 1
  • 1
Lee
  • 2,874
  • 3
  • 27
  • 51

0 Answers0