-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Code 127 - you may not have electron installed correctly #602
Comments
First off, your version numbers look like versions of NPM rather than versions of nightmare (latest is 2.3.4) or electron (latest is 0.37.7). You should only need to install nightmare, though. Are you running the install commands inside your virtual box or on OSX? Nightmare has a dependency on electron-prebuilt, which downloads a platform-appropriate binary on install. So if you're installing on OSX but running on Linux it won't find the Linux binary. |
I'm installing nightmare using |
For versions: electron-download is 2.1.1, prebuilt is 0.37.7, and nightmare is 2.3.4 |
What do you have installed in node_modules/nightmare/node_modules/electron-prebuilt/dist? Do you have any output from npm install? |
Nothing inside of node_modules/nightmare/node_modules. That directory doesn't exist. npm install outputs that the packages were installed correctly, from what I can tell. I can add the output here if you'd like to see it. |
To give a lil more context, here's the sample code I have that's failing.
That outputs:
|
You may want to run with |
@Mr0grog Just tried that. Getting this error now:
|
Ok, so you are at least missing libgtk, which Electron needs to run. You may want to look at #224 for a better sense of all the binary dependencies you need when running on Linux. |
I've got an update: I installed all the dependencies listed here: http://electron.atom.io/docs/v0.25.0/development/build-instructions-linux/ Now, my debug outputs literally nothing, even with Full command running:
EDIT: I was running the command wrong. Now here's the error I'm getting:
However, xvfb is installed and the newest version? EDIT 2: running |
Is it running? Generally you want to start Xvfb as a daemon process. Alternatively, you can Additionally, if you don’t have a system well-configured for running headlessly, there are a bunch of other things you’ll want to ensure are configured and running properly. Check out the scripts in Note also, if you are on Node v4+ (which is kind of a requirement now…?) you don’t need the |
@Mr0grog Do I need to? I was working under the assumption that nightmare would start the virtual display itself. Maybe that was my problem. |
Yes. In my experience, at least, it’s pretty unusual for any tool that uses an X Windows display to actually create one—the idea is usually that the program is simply asking the window server for a display to use (well, really a window to draw in, not even a display); it’s not really the program’s responsibility to worry about whether that display is real or virtual, how it’s managed, etc. There was some brief discussion not too long ago (#502 (comment)) about whether it would be useful to do this automatically, but I don’t know that it’s gone anywhere. |
Poking a head in:
I've been working on this off and on, but hit a snag with |
Okay. I'm currently trying out Phantom+Casper+Spooky, seeing if that works a lil better. If I can't get that running, I'll probably switch back to nightmare again. I'll be sure to update this issue provided that doesn't go well. |
Gave it a try again this morning. I'm using https://www.npmjs.com/package/xvfb to spin up my xvfb process prior to my code. However, I'm still getting EDIT: My code: My code:
EDIT - using node headless also doesn't work. I still get |
Nightmare is async, so at least part of your problem is this: xvfb.startSync();
Nightmare(...)
.goto('https://google.com')
.evaluate(function () {
return document.title;
})
.end()
.then(function (title) {
console.log(title);
});
// this stops xvfb before Nightmare even starts!
xvfb.stopSync(); Instead, you should be doing something more like: xvfb.startSync();
Nightmare(...)
.goto('https://google.com')
.evaluate(function () {
return document.title;
})
.end()
.then(function (title) {
console.log(title);
// wait to stop xvfb until nightmare is actually finished
xvfb.stop();
})
// and make sure to stop it even if something broke
.catch(function() {
xvfb.stop();
}); |
No dice. Even with |
What’s the actual electron output? |
Nothing. It just sits there. Using |
So… does it just sit, printing nothing, or does it print the error about Xvfb? If nothing, you’ve likely got some other issue, because that sounds like Electron isn’t even getting a chance to try and start. |
@Mr0grog It literally just sits, printing nothing. Switching to
I also get this error now:
EDIT: Never mind, now the original debug command is returning errors as well. Following output:
EDIT 2: We're back to nothing after I tweaked my code again. No output, process just hangs forever.
This outputs nothing again. Changing to
|
The following adapted from the example works on my headless box: var Xvfb = require('xvfb');
var Nightmare = require('nightmare');
var xvfb = new Xvfb({
silent: true
});
xvfb.startSync();
var nightmare = Nightmare({
show: false,
webPreferences: {
partition: 'custom'
}
});
nightmare
.goto('https://google.com')
.evaluate(function() {
return document.title;
})
.end()
.then(function(title) {
console.log(title);
xvfb.stopSync();
}); Is that what your modification looks like/what you're running? A couple of notes:
|
Okay, I'm basically starting from scratch. I re-provisioned my vagrant box. I'm reinstalling nightmare entirely via
|
Result, even after all that:
|
That's .... baffling. @yoz might have been on the right track, but the suggestion there looks like it would work for npm2, not npm3. If you look at I'd also be curious if you explicitly installed |
I have the same issue, the weird thing is it works perfectly on my laptop, but within my vps I got the Thanks a lot :-) EDIT: I ran the code provided by @jamesaspence and it's working, but i'm still willing not to use |
@paulintrognon You might want to take a look at #224. The short version is that Electron requires a framebuffer to render, and when you're running headlessly on Linux, running |
To solve this, I needed to install libxss. |
If you run with I'm going to go ahead and close this issue. If it crops up again, feel free to reopen/open a new issue. |
Hey guys, so for running nightmare in docker or server you need to install npm xvfb and always include it and use it? |
for getting electron run with xvfb on a headless ubuntu 16.04 system i needed to install following packages: |
@jamesaspence after all this, did you solve this problem with nightmare or did you start using another library? |
@idchlife I think (?) I got it working? Sorry I forgot to update this - I'll see if I can dig up some code. This was at a previous company so I'm not positive I'll be able to get access to the code and see how I resolved it. |
@jamesaspence thanks! Resolved it too. For anyone looking to solve this you may need xvfb problem check If you are using pm2 as I am, add env variable "DISPLAY": "xfvb_used_display_in_sh_script" You need to use .sh script for every pm2-docker start or pm2 start command. In this .sh script you will need FIRST to start xvfb then make pm2/pm2-docker start config.js (--only your_script if you want 1 script) env variable with DISPLAY should be inside every script config in config.js I after that you will run into permission denied error - increase docker shm_size to 1G or more if problem persists. Man I spent way too much time trying to figure this out |
@DonBras That was a time saver! |
In my case electron debug wrote: "electron: error while loading shared libraries: libgconf-2.so.4: cannot open shared object file: No such file or directory" |
I have done fresh installs of nightmare JS repeatedly, in an attempt to solve this issue. No dice.
I run
npm i nightmare
. It installs nightmare NPM version 3.3.6. It also installs electron for me. Electron-download NPM version 2.14.15 is installed, as well as electron-prebuilt NPM version 2.14.6.Running it inside of my virtual box (running Ubuntu 14.04.3), it produces the error
nightmare electron child process exited with code 127: command not found - you may not have electron installed correctly +8ms
.I have reinstalled multiple times. I've tried installing electron separately. No matter what I attempt, I always get that error.
I should point out, I can get the code to run perfectly on OSX. After I do a fresh reinstall outside of my virtual box, it works perfectly fine on OSX.
EDIT: Summary commands I have attempted:
npm uninstall electron && npm uninstall nightmare
npm i nightmare
npm i -g electron
npm i segmentio/nightmare
The text was updated successfully, but these errors were encountered: