How to run node in JavaScript file

A strong textJavaScript file can be run in the terminal only if you have Node.Js in your system. If you don’t have Node.js installed in your system then you can get it installed from this link.

Procedure

If you are done with the installation process we can move ahead to execute it in the terminal.

Step 1: Save your javascript with .js extension.

Step 2: Open the command prompt

Step 3: Locate your path where the .js file is saved.

Step 4: To compile the .js file we have to write

Node .js

Step 5: Press the Enter key.

Example

The above script file will be executed in the command prompt.

Then contents of the javascript file.

const add = (a, b) => {
return a + b
}

console.log(add(4, 6))

Output:

10

write your code here:Coding Playground

6 Likes

Check the node section for update

2 Likes

Thank you for this info

4 Likes

Thanks for the information

4 Likes

Thanks for this information

3 Likes