Indium icon indicating copy to clipboard operation
Indium copied to clipboard

Providing a working minimal example

Open Nathan-Furnal opened this issue 4 years ago • 5 comments

Hi,

I tried to setup a small test to play around with Indium :


mkdir test_js
cd test_js/
# Create the .indium.json, how ?
nano .indium.json
touch example.js
emacs example.js

This doesn't work.

My setup was the following during the experiment :

(use-package js2-mode
  :ensure t
  :defer t 
  :mode ("\\.js\\'". js2-mode))

(use-package indium
  :ensure t
  :defer t
  :config 
  (setq indium-chrome-executable "google-chrome"))

The minimal config :

{
  "configurations": [
    {
      "name": "Web project",
      "type": "chrome"
    }
  ]
}

When trying the M-x indium-launch, no url is recognized. Shouldn't it connect to localhost with some default settings?

If what I did is wrong, can someone point me at the correct way to do it?

Thanks for the help,

Nathan

Nathan-Furnal avatar Jul 23 '20 13:07 Nathan-Furnal

I'm new to web dev and Indium, the following setup works for me, M-x indium-launch starts a fresh Chrome instance then I can run JS code in the *JS REPL* buffer.

~ $ mkdir /tmp/test
~ $ cd /tmp/test
/tmp/test $ find-file .indium.json
#<buffer test/.indium.json>
/tmp/test $ cat .indium.json
{
    "configurations": [
        {
            "name": "Web project",
            "type": "chrome",
            "url": "file:///tmp/test/index.html"
        }
    ]
}
/tmp/test $ touch index.html

I use the builtin Emacs modes for HTML/CSS/JS and there is no real configuration for indium.

(use-package indium
  :ensure t
  :homepage https://github.com/NicolasPetton/indium
  :about A JavaScript development environment for Emacs
  :info (info "(Indium) Top"))

xuchunyang avatar Jul 27 '20 12:07 xuchunyang

@xuchunyang doesn't work for me. @NicolasPetton I agree with OP. I've tried for hours already to make this work. It worked initially (don't know how, exactly), then I've restarted indium and now it doesn't. I've looked at all the examples I could find. I either get the ECONNREFUSED or I get no warning/error but no response on indium-eval-last-node either. I'm using "file:///". I assume some server should be running for "localhost".

I'm just playing with JavaScript. I have a minimal ~/projects/javascript/play.js that I want to interact with. No fancy stuff. Just the minimal hello world project to get things started.

mihaiolteanu avatar Oct 28 '21 06:10 mihaiolteanu

I have been trying to get this to work for several hours, too, but no success. A minimal reproducible example would be great.

joshcho avatar Dec 01 '22 05:12 joshcho

If you're attempting to use Indium with chrome, one thing to test is that chrome is correctly opening the remote-debug-port. E.g. on my Mac, Indium by default runs /Applications/Google\ Chrome.app/Contents/MacOS/Google Chrome --remote-debugging-port=9222 — which does not actually open the remote debugging port unless I run with sudo.

One way you can test if chrome has actually opened the remote debugging port is to submit an HTTP request against it, e.g.: % curl localhost:9222/json

A workaround for chrome on Mac OS X is here: https://github.com/natkuhn/Chrome-debug/

ecyrb avatar Jan 18 '23 07:01 ecyrb

Another thing to try if you're getting ECONNREFUSED is to set your host to 0.0.0.0 in your config file. I had mine set to localhost and this seemed to convince Indium's CDP client to try IPv6.

ecyrb avatar Jan 18 '23 08:01 ecyrb