Run Inline using SpiderMonkey or V8

Running code inline doesn.t work for me, always when I try it. It doesn’t work.
If I run print("test") I get te follwing error.

C:\Users\Bob\AppData\Local\Temp\ko-runinline.buffer:1
(function (exports, require, module, __filename, __dirname) { print("test");
                                                              ^

ReferenceError: print is not defined
    at Object.<anonymous> (C:\Users\Bob\AppData\Local\Temp\ko-runinline.buffer:1:63)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:968:3

FAIL: 1

My file type is Javascript, but it tries to invoke node.js

Console.log is also working for me, but when I use print or alert i get an error.

When i have a php file and write echo ‘test’;

@Defman you will have a php opening tag in your file, but if you want to run a small piece of you’re code inline.
You might not want to run all the code between the opening tag and the code you want to run, for example working inside a class.

@careyh so if I’m correct, I cant use the run inline function on this list:

Understood.

Yes. Do you have an idea how a shell should handle that?

No, I don’t, maybe configure a other interpreter for javascript and use the node only for node.js.
Is it possible to configure a other interpreter for it and can you use spidermonkey for it?

Not sure you’re able to use other interpreter, but SpiderMonkey is very… limited.

I am not much of a Javascript guy, but I use console.log(“test”) and that works OK.

Louyo

File an enhancement request @babobski :slight_smile:

Found a extension(jsdom) for node.js witch brings the DOM to node.js maybe something like this can be implemented for javascript files?

Might be worth letting users define their own JS engine executables. That should be fairly simple to support. It would -only- be for run-in-line though.

Regardless, this should be an enhancement request on the bug tracker :slight_smile: