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

java.lang.RuntimeException: java.lang.Exception: node.exe couldn't be found in #6

Closed
empty-person opened this issue Nov 19, 2021 · 8 comments

Comments

@empty-person
Copy link

import com.osiris.headlessbrowser.HBrowser;
import com.osiris.headlessbrowser.windows.PlaywrightWindow;

public class Main {
public static void main(String[] args) {
HBrowser hBrowser = new HBrowser();
try (PlaywrightWindow window = hBrowser.openWindow()) {
window.load("https://example.com");
System.out.println(window.getInnerHtml());
} catch (Exception e) {
e.printStackTrace();
}
}
}

Error during installation of NodeJS. Details:
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception: node.exe couldn't be found in D:\Projects\WebDriverPleaseWork\headless-browser\node-js\download.zip
at com.osiris.headlessbrowser.windows.PlaywrightWindow.(PlaywrightWindow.java:192)
at com.osiris.headlessbrowser.windows.WindowBuilder.buildPlaywrightWindow(WindowBuilder.java:79)
at com.osiris.headlessbrowser.HBrowser.openWindow(HBrowser.java:30)
at Main.main(Main.java:7)
Caused by: java.lang.RuntimeException: java.lang.Exception: node.exe couldn't be found in D:\Projects\WebDriverPleaseWork\headless-browser\node-js\download.zip
at com.osiris.headlessbrowser.js.contexts.NodeContext.(NodeContext.java:151)
at com.osiris.headlessbrowser.windows.PlaywrightWindow.(PlaywrightWindow.java:58)
... 3 more
Caused by: java.lang.Exception: node.exe couldn't be found in D:\Projects\WebDriverPleaseWork\headless-browser\node-js\download.zip
at com.osiris.headlessbrowser.js.contexts.NodeContext.(NodeContext.java:144)
... 4 more

Process finished with exit code 0

@Osiris-Team
Copy link
Owner

I guess ur on Windows?

@Osiris-Team
Copy link
Owner

@empty-person
I sadly cannot reproduce the error with the provided information.
It could be that during the download/installation of NodeJs something went wrong.
Print the debug log System.out like this:

        HBrowser hBrowser = new HBrowser();
        try (PlaywrightWindow playwrightWindow = hBrowser.openCustomWindow()
                .debugOutputStream(System.out)
                .buildPlaywrightWindow()) {
            // ...
        } catch (Exception e) {
            e.printStackTrace();
        }

and share the result please.

@Osiris-Team
Copy link
Owner

Gonna close this for now since there was no response.

@nocelab
Copy link
Contributor

nocelab commented Feb 8, 2022

on Windows the first time I running my code:

Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: c:\temp\HBrowser\headless-browser\node-js\node.exe

... is missing node-v17.4.0-win-x64 in path, nodejs is installed in c:\temp\HBrowser\headless-browser\node-js\node-v17.4.0-win-x64

@Osiris-Team
Copy link
Owner

@nocelab Can u give the latest version a try. Also, delete the headless-browser folder just to be sure.

@nocelab
Copy link
Contributor

nocelab commented Feb 8, 2022

running PuppeteerWindowTest.java with 2.3.4 (sorry for italian console output):

[NPM-INSTALL] Installing 'puppeteer'...
[NPM-ERROR] npm ERR! code 1
[NPM-ERROR] npm ERR! path C:\WORK\node_modules\puppeteer
[NPM-ERROR] npm ERR! command failed
[NPM-ERROR] npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node install.js
[NPM-ERROR] npm ERR! "node" non è riconosciuto come comando interno o esterno,
[NPM-ERROR] npm ERR!  un programma eseguibile o un file batch.
[NPM-ERROR] 
[NPM-ERROR] npm ERR! A complete log of this run can be found in:
[NPM-ERROR] npm ERR!     C:\Users\user1\AppData\Local\npm-cache\_logs\2022-02-08T16_42_45_007Z-debug-0.log
Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalThreadStateException: process has not exited
	at com.osiris.headlessbrowser.windows.PuppeteerWindow.<init>(PuppeteerWindow.java:122)
	at com.osiris.headlessbrowser.windows.WindowBuilder.buildPuppeteerWindow(WindowBuilder.java:70)
	at com.osiris.headlessbrowser.PuppeteerWindowTest.main(PuppeteerWindowTest.java:10)
Caused by: java.lang.IllegalThreadStateException: process has not exited
	at java.base/java.lang.ProcessImpl.exitValue(ProcessImpl.java:539)
	at com.osiris.headlessbrowser.js.contexts.NodeContext.npmInstall(NodeContext.java:496)
	at com.osiris.headlessbrowser.windows.PuppeteerWindow.<init>(PuppeteerWindow.java:74)
	... 2 more

@Osiris-Team
Copy link
Owner

Oh ok looks like npm tries to run its install script via a system wide node installation, instead of the one installed by headleass browser in your current working dir, which is weird and doesnt happen for me.
Im gonna do some research on this.

@Osiris-Team Osiris-Team reopened this Feb 8, 2022
@Osiris-Team
Copy link
Owner

Related to: npm/rfcs#531
Going to prepend the node installation path and release an update later.

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

3 participants