Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ps-list 6.x is not working anymore using pkg due to embedded exe #23

Closed
Congelli501 opened this issue Oct 16, 2018 · 4 comments
Closed

Comments

@Congelli501
Copy link

I use pkg to package my node application into a single file.
Anything other than required js code is not embedded into the final build.

I chose ps-list because it was written purely in JS, but it's not the case anymore, for the Windows platform.

Using a prebuild exe may also cause problem on non x86 platforms, and, as the source code is not provided in the source tree, ps-list is not fully open source anymore (but that's easy to fix).

If possible, please go back to a pure js code, or provide a fallback mecanism if running the embedded exe doesn't work.

Here is the obvious and uninteresting error:

spawn C:\snapshot\dist\fastlist.exe ENOENT
Error: spawn C:\snapshot\dist\fastlist.exe ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:229:19)
    at onErrorNT (internal/child_process.js:406:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
@sindresorhus
Copy link
Owner

as the source code is not provided in the source tree, ps-list is not fully open source anymore (but that's easy to fix)

Sure it is: https://github.com/MarkTiedemann/fastlist

If possible, please go back to a pure js code, or provide a fallback mecanism if running the embedded exe doesn't work.

I'm not interested complicating it with a fallback. This module works perfectly with normal Node.js usage. It's up to pkg to support Node.js modules, not the other way around. Open an issue on pkg. You are also free to stay on the previous version.

@Congelli501
Copy link
Author

I was expecting this anwser, but it was worth trying :)

I stuck to the 5.x version for now, but I'm not comfortable not keeping my dependencies up to date.
I'll switch to an other project, as I prefer pure JS code, if possible, but that's a personal point of view.

@MarkTiedemann
Copy link
Contributor

@Congelli501 Feel free to use the underlying tasklist module directly. It's not "pure JS"; it's simply executing C:\Windows\System32\tasklist.exe which is present by default on modern Windows systems (but it doesn't have to be... it's just a file, too).

I also believe pkg allows you to specify external files which will be packaged into the binary (see: pkg#assets). Theoretically, all you'd have to do is to include ./node_modules/ps-list/fastlist.exe. I haven't tried it yet, but I'm sure you can get it to work just fine. :)

@xunilrj
Copy link

xunilrj commented Sep 1, 2021

Just for reference: even if one insert the executable in pkg asset list, it will not work. See: vercel/pkg#1002

You can't start exe processes from snapshot filesystem

and

That's probably the case, pkg probably just intercepts fs calls to /snapshot and resolves it with internal data.

For this use case, the first time your executable is run, you can get readable streams to the assets (binaries) you want, and write them into an external staged directory (maybe even a temp dir), or if you embedded a zip file, extract that into your staged dir.

Then you can spawn the executables with that path on your actual local filesystem.

The simplest solution would be to specify the "bin" folder in options.

let tasks = await psList({path:"..."});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants