pkg
pkg copied to clipboard
Profile.json gets baked into .exe
Hi, I want to be able to edit my Profile.json and have my code be able to read any new changes, but when packaging it bakes in the profile.json there for I'm not able to edit it. How should I go about importing this json file.
Use fs to read a file on runtime and leave Profile.json out while packaging.
Example:
const fs = require('fs')
fs.readFile("Profile.json", "utf8", function (err, json) {
if (err) console.error(err)
else {
const profile = JSON.parse(json);
// your code
}
}
Note that Profile.json has to be in the same directory as the .exe in this example. You also can define a path to a subfolder on fs.readFile().