pkg icon indicating copy to clipboard operation
pkg copied to clipboard

Downloading Then running Error

Open Kief5555 opened this issue 1 year ago • 1 comments

What version of pkg are you using?

5.8.0

What version of Node.js are you using?

18.2.0

What operating system are you using?

macOS Ventura beta 3 and Windows 10

What CPU architecture are you using?

Intel

What Node versions, OSs and CPU architectures are you building for?

node 14 for Mac and windows

Describe the Bug

When downloading an executable then running it, I receive this:

Error: File or directory '/**/KiefTools/FireFox.exe' was not included into executable at compilation stage. Please recompile adding it as asset or script.

Here's the code for downloading then executing.

const { exec1 } = require('pkg')

https.get(url1, (res) => {
                const path = `${__dirname}/deploy/Test.exe`;
                const filePath = fs.createWriteStream(path);
                res.pipe(filePath);
                filePath.on('finish', () => {
                    filePath.close(function() {});
                    
                })
            })
            https.get(url2, (res) => {
                const path = `${__dirname}/test.bat`;
                const filePath = fs.createWriteStream(path);
                res.pipe(filePath);
                filePath.on('finish', () => {
                    filePath.close(function () {
                        var exec = require('child_process').execFile;
                        var fun = function () {
                            exec1(`${__dirname}/deploy/Test.exe`, function (err, data) {
                                console.log(err)
                                console.log(data.toString());
                            });
                        }
                        setInterval(fun, 1000);
                        console.log(chalk.redBright(`PASTE THIS INTO TEST EXE: ${__dirname}/bat and press enter!`))
                        readline.question('Press enter to exit...')
                        exit(0)
                    });

Expected Behavior

It downloads and runs

To Reproduce

By using the code above

Kief5555 avatar Jul 20 '22 13:07 Kief5555

                const { execFile } = require('child_process');

                const child = execFile('Exe', [], (error, stdout, stderr) => {
                    if (error) {
                        throw error;
                    }
                    console.log(stdout);
                });
            },
            2000);

using that gives a different error. Screenshot 2022-07-20 at 5 50 51 PM

Kief5555 avatar Jul 21 '22 00:07 Kief5555