I have a linked local custom node_module that needs to use the projects file directory: /tmp in order to dump a file there during run time. How can I direct my custom node_module to this directory?
I have tried accessing root using nodes internal path utility but this just stays within the node_modules folder.
Trying to access tmp folder by using:
var root = require('find-root')(path.resolve(__dirname));
this.tmpDir = path.resolve(root, 'tmp');
Outputs:
"/Users/me/Documents/Project/Billing/server/node_modules/processremote/tmp"
But I need it to navigate (back out of) to:
"/Users/me/Documents/Project/Billing/server/tmp"
find-root
returns the directory of the closestpackage.json
, which in your case is the directory of the child module itself (since it has apackage.json
file and is closest to the script).You can fix this by using
path.join(root, '../..', 'tmp')
(instead of the currentpath.resolve(root, 'tmp')
):