pkg icon indicating copy to clipboard operation
pkg copied to clipboard

Generated Windows executable doesn't run successfully with Node 10 target

Open alza-bitz opened this issue 7 years ago • 14 comments

Given Project: https://github.com/digital-dj-tools/mp3-parser pkg version: 4.4.0 pkg targets: node10-win-x64,node10-macos-x64,node10-linux-x64

npm install
clojure -Acompile-cljs
npm run build

Expected The Windows and Linux generated executables run ok (I can't test the Macos executable, I don't have a Mac).

Actual The Linux executable runs successfully, but the Windows executable does not.

From Bash (WSL)

/mnt/d/Projects/mp3-parser/pkg$ ./mp3-parser-linux ./test-resources/lame-mp3-cbr-stereo-44100khz-192kbps-id3v2.mp3
<generates correct output>

From CMD (Windows)

D:\Projects\mp3-parser\pkg>mp3-parser-win.exe ..\test-resources\lame-mp3-cbr-stereo-44100khz-192kbps-id3v2.mp3
<no output>
D:\Projects\mp3-parser\pkg>echo %errorlevel%
-1073741819

However, if I change targets to node8-win-x64,node8-macos-x64,node8-linux-x64, the Windows and Linux generated executables run ok.

Why do some of the generated executables (Windows) not run successfully with Node 10?

alza-bitz avatar Oct 10 '19 01:10 alza-bitz

I'm seeing the same issue when targetting node10-win-x86

When running an exe packaged with 4.4.0 I see an error Pkg: Error reading from file

It works correctly when packaged with 4.3.8

chrisbednarski avatar Oct 14 '19 00:10 chrisbednarski

Yes, there is a compatibility issue with node@10 and [email protected]. It will work with [email protected] or [email protected].

rao123dk avatar Oct 18 '19 13:10 rao123dk

I confirm, that using [email protected] will fail to produce an exe for windows 10. Using same config and module with [email protected] works.

thanks @rao123dk

gabrielstuff avatar Nov 03 '19 23:11 gabrielstuff

Same for newer 4.4.x releases

Fadoli avatar Jan 14 '20 13:01 Fadoli

I can confirm I could successfully compile a Mac target from Windows using [email protected]. I had to chmod +x the file on the Mac, though.

Danita avatar Feb 20 '20 14:02 Danita

I had exact same problem and it solved with command below:

pkg ./dist/index.js --target node12-win-x64 --options max_old_space_size=4096

saostad avatar Jul 16 '20 17:07 saostad

I faced the same problem!

albertininm avatar Jul 22 '20 17:07 albertininm

still an issue, tried 4.3.x with node10-and-lower on win, no combinations working. Exe opens and exists immediately.

Nashorn avatar Jan 25 '21 16:01 Nashorn

@Nashorn check this file. You should use one of them in order to get it working.

albertininm avatar Jan 25 '21 17:01 albertininm

@albertmourato thanks for your help. I've tried a number of diff combinations, can't say I tried them all on that list. At this point its trial and error (windows only), the thing works flawlessly on mac/linux.

Let me share my config and small example, maybe i have it configured wrong? Basically making a self-executing server (using the npm http-server module) that launches a localhost from the folder it is opened from. Works perfect like i said on macos/linux, just not on Windows, even with various targets and diff versions of PKG. CMD window opens to black screen and closes immediately.

When i cd into folder an open the .exe, i see my logs fine, no errors, and cmd stays open. No idea at this point. Any help appreciated:

{
    "name": "pkgtest",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "author": "test",
    "scripts": {
        "start": "http-server ./ -o index.html"
    },
    "bin": "$DIR/node_modules/http-server/bin/http-server",
    "dependencies": {
        "http-server": "^0.12.3"
    },
    "assets": [
        "./node_modules/*",
        "./node_modules/http-server"
    ]
}

And index.js:

var http_server = require("http-server");
var path = require("path");
const cwd = process.cwd();
var exec = require('child_process').exec;
var s = process.execPath;
    s = s.substr(0,s.lastIndexOf("/"));


    console.log("app path",s);//not used
    console.log("process.execPath",path.dirname(process.execPath));
    console.log("process.cwd",process.cwd());
    console.log("process.pkg",process.pkg);
    console.log("process.versions",process.versions)
    if(http_server){
        console.log("http_server", "successs");
    }else{
        console.log("http_server", "Server module not found")
    } 
    process.chdir(path.dirname(process.execPath));
    console.log("changed dir to",process.cwd());
    console.log("Starting npm");
    exec("npm start")
    process.exit();

Also, after the exe is built, i copy it into a "test" folder that has 1 index.html file as well as a node_modules/ folder with http-server installed in there. So on mac, it launches the localhost server on the folder at :8080, i am 90% there

Nashorn avatar Jan 26 '21 14:01 Nashorn

any help on this?

Nashorn avatar Feb 03 '21 08:02 Nashorn

its a dead simple example, no one from pkg team knows?

Nashorn avatar Feb 09 '21 09:02 Nashorn

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

github-actions[bot] avatar May 11 '21 00:05 github-actions[bot]

This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.

github-actions[bot] avatar May 16 '21 00:05 github-actions[bot]