Another answer would be the NodeJS!
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
Using terminal you will be able to start it using node command.
$ node
> 2 + 4
6
>
Note: If you want to exit just type
.exit
You can also run a JavaScript file like this:
node file.js
« Install it NOW »
Answer from Ionică Bizău on Stack OverflowAnother answer would be the NodeJS!
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
Using terminal you will be able to start it using node command.
$ node
> 2 + 4
6
>
Note: If you want to exit just type
.exit
You can also run a JavaScript file like this:
node file.js
« Install it NOW »
If you have MacOS you can get jsc a javascript console by typing on Terminal.app:
/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Helpers/jsc
On older versions of OS X, the jsc command is located at:
/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc
You could also run one of your .js script by adding its name as an argument for jsc, like this:
jsc your_awesome_script_name.js
Notice: I use console.log() during development but jsc needs the debug() function instead.
On Ubuntu you have some nice ECMAScript shells at your disposal. Between them it's worth to mention SpiderMonkey. You can add It by sudo apt-get install spidermonkey
On Windows as other people said you can rely on cscript and wscript directly built on the OS.
I would add also another :) way of thinking to the problem, if you have time and like to learn new things i'd like to mention coffee-script that has its own compiler/console and gives you super-correct Javascript out. You can try it also on your browser (link "try coffeescript").
UPDATE July 2021:
You can also install and use the brilliant QuickJS which on OS X could be installed via brew install quickjs. Then an interactive console will be available at your propmt with qjs
Videos
What control do we have over the project?
What is meant by Agile software development?
How can we log support calls with you?
complete beginner here so please excuse the terminology and the lingo....
if i wanted to simply spit something out like
console.log('hello');
how do i essentially run that?
like in python, i know that i can just write something like
print('hello')
open the terminal change the cd and run it from there, but im not really familiar with the way that js is structured.
i looked at this here but it was not really making any sense to me unfortunately .
can someone provide some really simple clarity ?
The answer to your other question told you to run NPM commands outside of the node.js terminal. npm is a keyword that tells the command prompt to use a particular application to process the commands or arguments. In your case you're trying to run a js server written for node.js so rather than using npm install ... you would use probably use node server1.js (if you're trying to run it outside of the node.js terminal window, after cd'ing to the appropriate directory)
Sorry, just saw this question is old. Hopefully you got it by now and this post will help someone else just learning.
The code is fine, but it was written for a different runtime. WScript is very different from node.js (just like both are different from the "usual" web-browser environment) – for example, it does not support require() nor console. (Technically it's not even JavaScript but JScript.)
You will have to download node.js for Windows.