Wednesday 30 March 2016

Making files 'generalizable'

I have a variable defined byvar CustomerProducts = require('/Users/MyName/Desktop/JavaScriptFun/CustomerProducts.json')But this file will be downloaded by multiple other users, so for each person who downloads the js and json file, it won't be under '/Users/MyName/' but '/Users/TheirName/', so I can't have my code reference the file by that address in the code.Also later I use fs.writeFile to save a file to the same directory. How could I change all of this?Edit: Also I'm coding this on a Mac, and they're downloading it on Linux. Not sure if that changes anything, but thought I should mention.

Submitted March 30, 2016 at 05:18PM by asdfCode

No comments:

Post a Comment