简体   繁体   中英

Open file from route in Express

I have developed a Node module which needs a configuration file (CSV). I am trying to use this module within an Express Route module. The problem is that the module fails to load the configuration file.

What kind of Path should I use? relative to the module? relative to the route? relative to the express project folder?

I have used the path module to resolve the relative path

    var url="/relativeDir1/relativeDir2";
    var pathModule = require("path");
    var path =  pathModule.resolve(path.join(__dirname, url));

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