We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this questionI have to work on the Windows platform for a project, and I happen to do that project with server-side javascript (yes, I am actually using server-side javascript). Most of my analysis and research I do by working with JSC on my Mac, which allows me to write code and get back a response from the interpreter and load .js files. Now I have been googling and I find most of the results about Firebug or online tools. However, I am looking fo开发者_开发问答r something more commandlinish.
Does anyone have a good recommendation for a JavaScript interpreter/console application for the Windows platform that does not require a browser and can be run from the commandline (and supports the loading of external .js files) ?
Many thanks,
node.js has a Windows version. The installer is completely non-invasive, all it does is copies files to Program Files and adds the path to your system $PATH env. variable. If you then start node.exe without parameters it works as a REPL Javascript console.
You can load a .js file like this:
> .load ./file/to/myscript.js
Check out REPL page in Node.js manual for more info.
If you don't want to install any external tools, you can use Windows built in cscript.exe and a short script to read/eval/print/loop as follows:
try {
throw {};
} catch(repl) {
while (repl.line != '.exit') {
if (repl.line) {
repl.err = null;
try {
repl.out = eval('(' + repl.line + ')');
} catch (e) {
if (e instanceof SyntaxError) {
try {
repl.out = eval(repl.line);
} catch (e) {
repl.err = e;
}
} else {
repl.err = e;
}
}
if (repl.err) {
WScript.stdout.writeLine('Error: ' + repl.err.message);
} else {
WScript.stdout.writeLine(repl.out == null ? String(repl.out) : (typeof repl.out.toString == 'function' ? repl.out.toString() : Object.prototype.toString.call(repl.out)));
}
}
WScript.stdout.write('> ');
repl.line = WScript.stdin.readLine();
}
}
Save that as repl.js and run cscript repl.js
to get a console similar to jsc.
if your java runtime >=1.5 ,you can try jrunscript
. It is based on java scriptengines, JavaScript is the default language supported.
Not exactly equivalent to JSC, but still..
I use the browser's development tools (F12), and there I enter the Console tab. That's it.
Works with modern browsers, where Firefox usually needs Firebug for this.
The main advantage is to have an interactive interpreter, without the need to load a real file.
http://www.phpied.com/javascript-shell-scripting/ -> this might help your cause.
Rhino Shell - https://developer.mozilla.org/en/Rhino_Shell
Apart from Node.js, JSDB is quite nice. I checked node.js again and I believe it is now available as a single executable, node.exe, which is even more compact than JSDB. So I might be using that instead.
Just check out DeskJS (https://deskjs.wordpress.com). It's exactly what you're looking for! It's a portable Windows console application that lets you run pure JavaScript code and even load any existing JS files. It supports even the basic JS popup boxes implemented in browsers. You can save your commands as JS files that can be run on startup or by dragging-and-dropping them on the app. Plus there's so much more to it like you can create a build system for Sublime Text that can run JS files via cmd, it supports themes and snippets e.t.c...
精彩评论