How to Run Javascript in a node.js Command Prompt


In this article, we show how to run javascript in a node.js command prompt.

When you download the node.js software from their official website, it comes with a Node.js command prompt.

In this node.js command prompt, you can run Javascript, just as you would on the front end.

Even though node.js is meant to run Javascript on the back end, the server side, the node.js command prompt can still be used to run Javascript as if it were the front end.

So in order to do this, open up the node.js command prompt and enter in the following below.

After you do this, you should see the expression, Welcome to Node.js

You can then run commands just as you would with front end Javascript.

One thing that can be done is mathematical operations, such as addition operations.

And you can use standard Javascript functions such as toUpperCase() function to make a string all uppercase characters.

This is shown below.

Running javascript in a node.js command prompt

After, if you want to exit, you simply enter in, .exit - and this gets you out of the program.

And this is how to run javascript on a node.js Command prompt.

Related Resources

How to Find the Version of node.js Installed on Your Computer

HTML Comment Box is loading comments...