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

PowerJS fails to start if pwsh is not installed #7

Open
rsmarples opened this issue Jan 3, 2024 · 2 comments
Open

PowerJS fails to start if pwsh is not installed #7

rsmarples opened this issue Jan 3, 2024 · 2 comments

Comments

@rsmarples
Copy link
Contributor

child_process:spawn does not throw any error directly as it forks a process
Instead, errors are emitted and need to be listened to.
error is emitted on errors, and spawn on success.
https://nodejs.org/api/child_process.html#event-error

As such, only the first element of additionalShellNames is considered.

Workaround for vanilla windows without PowerShell-7:

const psOptions = {
    additionalShellNames: ['powershell'],
    extensions: [],
    dlls: {}
};
const ps = new PowerJS(psOptions);
@mdodge-ecgrow
Copy link

mdodge-ecgrow commented Feb 6, 2024

I was having issues getting this to run in my Node. I installed Powershell 7 and still got the same errors. Then I tried using the options above and now getting this error: Powershell init has an error!. Any ideas? Is there a debug mode?

If I remove the options object, I get these errors:
Error: spawn pwsh ENOENT.
Error: Shell took too long to start!.

@rsmarples
Copy link
Contributor Author

Whilst I have contributed to this project, I felt that the design is unworkable.
To fix the issue and the equally important issue of getting a decent error message when things go wrong would have
involved breaking the API to much.

I have created simpler more light weight variant PowerShell-Host which is available as a npm.

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

2 participants