8000 ShellJS works in Electron in one app, but gives Error 'Unable to find a path to node binary' in another · Issue #704 · shelljs/shelljs · GitHub
[go: up one dir, main page]

Skip to content

ShellJS works in Electron in one app, but gives Error 'Unable to find a path to node binary' in another #704

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

Closed
bmcgonag opened this issue Apr 18, 2017 · 14 comments
Labels
electron Bugs specific to the electron framework wontfix

Comments

@bmcgonag
Copy link

Node version (or tell us if you're using electron or some other framework):

Electron 1.6.2 (non-working app installed globally)

Electron 1.4.13 (working app installed as dev dependency for this app only).

I apparently installed Electron locally on one folder, and then globally later.

ShellJS version (the most recent version/Github branch you see the bug on):

ShellJS 0.7.7 (non-working app)

ShellJS 0.7.5 (working app)

Operating system:

MacOS and Ubuntu Linux 16.04 LTS

Description of the bug:

In one setup I'm using ShellJS with no issue running shells.exec() and my command runs fine.

In the new setup I'm using ShellJS with a globally installed Electron, and I get an 'Unable to find a path to node binary' message. It suggests setting the path manually, but I see some issues with this. If I distribute the app, this won't work for everyone else, right?

Example ShellJS command to reproduce the error:

Just pick one.

@bmcgonag
Copy link
Author

As a follow up. I uninstalled shelljs 0.7.7 and installed 0.7.5 in it's place, and it's now running the commands just like in my other app.

Seems to be something that has changed in shells since 0.7.5 that has caused this break.

@nfischer
Copy link
Member

We don't support electron yet. See this wiki page. Do you see this message when invoking non-exec commands?

#636 introduced this. This was intended to give better control for Electron support (e.g. config.execPath = shell.which('node') if that's good enough).

If you're interested in electron support, I'll gladly review a pull request.

@nfischer
Copy link
Member
nfischer commented Jun 7, 2017

Closing this, because we don't provide electron support. If someone wants to help us out here, we'll gladly revisit this.

@nfischer nfischer closed this as completed Jun 7, 2017
@nfischer nfischer added electron Bugs specific to the electron framework wontfix labels Jun 7, 2017
@achekulaev
Copy link
shell.config.execPath = shell.which('node')
shell.exec(...)

works just fine.

I wonder why there is a need to specify this manually if shell.which is actually able to find node binary, but other that that, it works.

@nfischer
Copy link
Member
nfischer commented Feb 4, 2018

I wonder why there is a need to specify this manually if shell.which is actually able to find node binary, but other that that, it works.

shell.which('node') isn't perfect: the node binary might be named nodejs (or any name).

I'm not opposed to trying shell.which() before throwing an error to the user. Feel free to send a PR.

@mayankvadia
Copy link

I had tried with node and nodejs but both are not working for me in window os

var shell = require('shelljs')
console.log("shell.config.execPath",shell.config.execPath) // return null
shell.config.execPath = shell.which('nodejs');

@nfischer
Copy link
Member

@mvkanha do you have node installed on your system?

@mayankvadia
Copy link

@nfischer Yes I have installed node on my system

@nfischer
Copy link
Member

@mvkanha then specify the full path to your installed node binary.

@dkapanidis
Copy link

I had tried with node and nodejs but both are not working for me in window os

var shell = require('shelljs')
console.log("shell.config.execPath",shell.config.execPath) // return null
shell.config.execPath = shell.which('nodejs');

The following worked for me, since the output is a ShellString

    shell.config.execPath = String(shell.which('node'))

@nfischer
Copy link
Member

@Spiddy I updated the wiki with a modification of your suggestion (We explicitly support .toString()). #704 (comment) is also an option for anyone willing to send a PR.

@linonetwo
Copy link

After bundling, shell.which('node') will be undefined, so

shell.config.execPath = shell.which('node').toString(); won't work.

@aayusharora
Copy link

How can we solve this after bundling?

@stjava
Copy link
stjava commented Sep 9, 2021

I also encountered this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron Bugs specific to the electron framework wontfix
Projects
None yet
Development

No branches or pull requests

8 participants
0