I have a JS filter which checks for the ether transferred in a recent transaction. I have loaded this script from the interactive JS console and it's working fine. Based on the ether in the transaction, I want to run external python scripts. For e.g.(Not actual code):

if (ether = 10){

And the node.js code for these functions:

function test1() {
    var spawn = require("child_process").spawn;
    var pc1 = spawn("python",["/path/to/test1.py"]);

This code is working fine when I execute it separately. But when I include this in the JS snippet and reload it to the console(using loadScript()), I get the following error:

err: cannot find module 'child_process'

child_process is a default node.js module. I understand that this is not a problem with the code but with the integration of node.js into geth client. Is this not possible at all or are there any workarounds?


2 Answers 2


In few cases node modules would not work in your browser. But there are modules which you can do read here http://www.richardrodger.com/2013/09/27/how-to-make-simple-node-js-modules-work-in-the-browser/#.V3Vco-t97IU.

In your case, it is not possible here

  • I don't have much knowledge about node.js. Here, Why is web3.js library being compared to a browser?
    – galahad
    Commented Jul 26, 2016 at 18:07
  • @varm a typo fixed it. Commented Jul 26, 2016 at 18:27
  • I'm not using any browser here. I was just asking whether default node.js modules like child_process will work if I load a script containing these modules to the JavaScript console of geth.
    – galahad
    Commented Jul 26, 2016 at 18:37
  • the Javascript console github.com/ethereum/go-ethereum/wiki/JavaScript-Console, and I believe no it won't work. Commented Jul 26, 2016 at 18:45
  • Any idea why it won't work?
    – galahad
    Commented Jul 26, 2016 at 19:25

I think you can do this by starting the console (or attaching to it later) with a 'preload' argument, eg i was able to load the library "ramda" from my local filesystem with:

geth --preload=/ABSOLUTE_PATH_TO_JS_LIBRARIES/ramda.min.js attach

(use "console" instead of "attach" if you don't already have a geth instance running that you want to attach to)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.