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

Error: Cannot find module '${HOME}/host.js' #118

Open
justfortherec opened this issue Jan 6, 2023 · 0 comments · May be fixed by #119
Open

Error: Cannot find module '${HOME}/host.js' #118

justfortherec opened this issue Jan 6, 2023 · 0 comments · May be fixed by #119

Comments

@justfortherec
Copy link

I am unable to connect Firefox with the native client because the path to host.js in the run.sh script is not found.

This is the error message that I see in the browser console:

NS_ERROR_ILLEGAL_VALUE: Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsINativeMessagingPortal.closeSession] [NativeMessaging.jsm:360](resource://gre/modules/NativeMessaging.jsm)
stderr output from native app com.add0n.node: node:internal/modules/cjs/loader:998
stderr output from native app com.add0n.node:   throw err;
stderr output from native app com.add0n.node:   ^
stderr output from native app com.add0n.node: 
stderr output from native app com.add0n.node: Error: Cannot find module '${HOME}/host.js'
stderr output from native app com.add0n.node:     at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
stderr output from native app com.add0n.node:     at Module._load (node:internal/modules/cjs/loader:841:27)
stderr output from native app com.add0n.node:     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
stderr output from native app com.add0n.node:     at node:internal/main/run_main_module:23:47 {
stderr output from native app com.add0n.node:   code: 'MODULE_NOT_FOUND',
stderr output from native app com.add0n.node:   requireStack: []
stderr output from native app com.add0n.node: }
stderr output from native app com.add0n.node: 
stderr output from native app com.add0n.node: Node.js v18.12.1
OperationError: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: Object does not exist at path “/org/freedesktop/portal/desktop/session/1_3947/firefox_com_add0n_node_4064532493”

(Note that I've replaced the actual path to my home directory with ${HOME} when copying the message)

It appears that Firefox starts the native client from $HOME as the working directory.
That leads to the script resolving the relative path host.js as $HOME/host.js.

I was able to fix this by applying the following tiny patch to run.sh:

 #!/usr/bin/env bash
-/usr/bin/node host.js
+/usr/bin/node $(dirname "$0")/host.js

This prefixes the host.js filename with the directory of the run.sh file — regardless of the working directory and regardless of the directory in which run.sh and the JavaScript files are located (as long as they are in the same location).

justfortherec added a commit to justfortherec/native-client that referenced this issue Jan 6, 2023
It appears that Firefox starts the native client from `$HOME` as the working directory.
That leads to the script resolving the relative path host.js as `$HOME/host.js`.

This fix prefixes the `host.js` filename with the directory of the run.sh file.
Now it works regardless of the working directory and regardless of the directory in which
`run.sh` and the JavaScript files are located (as long as they are in the same location).

Fix: andy-portmen#118, andy-portmen#116
justfortherec added a commit to justfortherec/native-client that referenced this issue Jan 6, 2023
It appears that Firefox starts the native client from `$HOME` as the working directory.
That leads to the script resolving the relative path host.js as `$HOME/host.js`.

This fix prefixes the `host.js` filename with the directory of the run.sh file.
Now it works regardless of the working directory and regardless of the directory in which
`run.sh` and the JavaScript files are located (as long as they are in the same location).

Fix: andy-portmen#118
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant