I thought Node.js was for server-side JS, what does it have to do with running it in the terminal?

I am currently following this article which demonstrates how we can run a JavaScript program in our terminal using Node.js. However, in previous articles I have read on Codecademy, I understood that Node.js was used for server-side programming. This means that Node.js allows us to do backend development with JavaScript

However, what I don’t understand is what does node have to do with running JavaScript in the terminal? I thought node was only used for backend development, right? Not for executing JS code in the terminal

Can someone please explain node.js fully?

How should a back-end developer develop a back-end if he can’t install the software he needs to build his application?

you can install node on your computer, and use that to run “JavaScript”. However, the node engine is not entirely the same as the JavaScript engine from your browser.

you can also just make a html file and a JavaScript file, link these files and then open the html file in your browser. Or there are sites like codepen.io, jsbin and jsfiddle (and many more) to simplify this process.

1 Like

After I read the article, I saw that node can be used for many things:

  • backend development
  • it can be used as a REPL (something like codepen, REPL.IT, or even the console)
  • and it can be used to run JavaScript files

However, I was wondering if the two last ‘features’ are just bonuses. Is Node.js mainly used for backend development but it can also be used as a REPL and to run JS scripts?

EDIT: I just read this from the next article:

Node.js is a JavaScript runtime, or an environment which runs JavaScript code outside of the browser

Now, I understand that Node.js simply allows us to run JavaScript code outside of the browser. This can be either for backend development, or we can then use it as a REPL, or to load JavaScript files, right?

but the nodeJS engine is not identical to the browser JS engine. The node engine has no console.log() for example.

these features are useful for back-end development as well.

1 Like

Ok, thank you so much :slightly_smiling_face:

I tried it out, and it worked

1 Like

So, downloading node.js is like creating a server-like environment to run and test javascript?

There are some differences between the node engine and the browser engine:

What is Node.js and how does it differ from a browser | by Joao Santos | The Startup | Medium

not sure how good this article explains things, I have not used nodeJS, so difficult to judge the quality of the blog post