-
Notifications
You must be signed in to change notification settings - Fork 1k
Error with external files read with fs.readFileSync are not included in pkg bundle #521
Comments
fixed using
and in my package.json I added:
|
@Ks89 how about using |
I never tried, sorry |
Well, I was able to fix it by reading the docs. I added a few lines to the source code. // Set the path of the project folder base on whether it is run with nodejs or as an executable
let project_folder;
if(process.pkg){
// It is run as an executable
project_folder = path.dirname(process.execPath)
}else{
// It is run with nodejs
project_folder = __dirname
} Then I change the call to fs.writeFile(path.join(project_folder, 'assets', 'my_image.png')) |
This issue comes up on Google when searching for node pkg error reading from file. I get this error message when using FWIW I have not found a better way to set the Windows executable icon. |
I got it fixed my listing the exact path in the
see #893 (comment) |
Hi!
In my project I'm reading an external file (a private rsa key with extension .key) with this code:
I'm able to build the project with pkg 4.3.4, but when I run the final binary file created by pkg I get this error:
If I copy this file next to the binary created by pkg, I can read it, otherwise no. So I suppose that It's not included in the final binary file created by pkg.
How can I fix this?
The text was updated successfully, but these errors were encountered: