Run Javascript File using terminal/cmd

2 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$39.99
List Price:  $79.99
You save:  $40
€38.14
List Price:  €76.29
You save:  €38.15
£31.54
List Price:  £63.08
You save:  £31.54
CA$57.29
List Price:  CA$114.60
You save:  CA$57.30
A$63.43
List Price:  A$126.88
You save:  A$63.45
S$53.61
List Price:  S$107.25
You save:  S$53.63
HK$310.88
List Price:  HK$621.85
You save:  HK$310.96
CHF 35.89
List Price:  CHF 71.79
You save:  CHF 35.90
NOK kr446.44
List Price:  NOK kr893
You save:  NOK kr446.55
DKK kr284.47
List Price:  DKK kr569.01
You save:  DKK kr284.54
NZ$70.32
List Price:  NZ$140.67
You save:  NZ$70.34
د.إ146.86
List Price:  د.إ293.76
You save:  د.إ146.90
৳4,864.77
List Price:  ৳9,730.75
You save:  ৳4,865.98
₹3,487.56
List Price:  ₹6,976
You save:  ₹3,488.43
RM177.73
List Price:  RM355.51
You save:  RM177.78
₦59,972.20
List Price:  ₦119,959.40
You save:  ₦59,987.20
₨11,206.48
List Price:  ₨22,415.77
You save:  ₨11,209.29
฿1,355.64
List Price:  ฿2,711.62
You save:  ฿1,355.98
₺1,456.58
List Price:  ₺2,913.53
You save:  ₺1,456.95
B$231.86
List Price:  B$463.79
You save:  B$231.92
R736.67
List Price:  R1,473.53
You save:  R736.86
Лв74.65
List Price:  Лв149.32
You save:  Лв74.67
₩57,694.17
List Price:  ₩115,402.78
You save:  ₩57,708.60
₪141.94
List Price:  ₪283.92
You save:  ₪141.98
₱2,317.18
List Price:  ₱4,634.94
You save:  ₱2,317.75
¥5,992.36
List Price:  ¥11,986.23
You save:  ¥5,993.86
MX$814.85
List Price:  MX$1,629.92
You save:  MX$815.06
QR145.97
List Price:  QR291.99
You save:  QR146.01
P551.93
List Price:  P1,104.01
You save:  P552.07
KSh5,170.70
List Price:  KSh10,342.70
You save:  KSh5,172
E£2,024.93
List Price:  E£4,050.37
You save:  E£2,025.44
ብር5,172.16
List Price:  ብር10,345.61
You save:  ብር5,173.45
Kz36,577.52
List Price:  Kz73,164.18
You save:  Kz36,586.66
CLP$37,688.17
List Price:  CLP$75,385.77
You save:  CLP$37,697.60
CN¥290.65
List Price:  CN¥581.38
You save:  CN¥290.72
RD$2,495.95
List Price:  RD$4,992.52
You save:  RD$2,496.57
DA5,390.70
List Price:  DA10,782.75
You save:  DA5,392.05
FJ$92.08
List Price:  FJ$184.18
You save:  FJ$92.10
Q308.70
List Price:  Q617.49
You save:  Q308.78
GY$8,376.96
List Price:  GY$16,756.02
You save:  GY$8,379.05
ISK kr5,549.81
List Price:  ISK kr11,101.01
You save:  ISK kr5,551.20
DH397.13
List Price:  DH794.36
You save:  DH397.23
L745.87
List Price:  L1,491.94
You save:  L746.06
ден2,348.10
List Price:  ден4,696.80
You save:  ден2,348.69
MOP$320.60
List Price:  MOP$641.29
You save:  MOP$320.68
N$736.71
List Price:  N$1,473.62
You save:  N$736.90
C$1,473.52
List Price:  C$2,947.42
You save:  C$1,473.89
रु5,581.69
List Price:  रु11,164.79
You save:  रु5,583.09
S/147.36
List Price:  S/294.77
You save:  S/147.40
K161.20
List Price:  K322.45
You save:  K161.24
SAR149.98
List Price:  SAR300
You save:  SAR150.01
ZK1,134.16
List Price:  ZK2,268.62
You save:  ZK1,134.45
L189.83
List Price:  L379.72
You save:  L189.88
Kč952.76
List Price:  Kč1,905.76
You save:  Kč953
Ft15,242.96
List Price:  Ft30,489.74
You save:  Ft15,246.77
SEK kr426.39
List Price:  SEK kr852.88
You save:  SEK kr426.49
ARS$42,434.18
List Price:  ARS$84,878.98
You save:  ARS$42,444.79
Bs276.68
List Price:  Bs553.44
You save:  Bs276.75
COP$165,184.63
List Price:  COP$330,410.57
You save:  COP$165,225.94
₡20,250.21
List Price:  ₡40,505.50
You save:  ₡20,255.28
L1,023.79
List Price:  L2,047.85
You save:  L1,024.05
₲317,221.09
List Price:  ₲634,521.52
You save:  ₲317,300.42
$U1,704.47
List Price:  $U3,409.37
You save:  $U1,704.90
zł157.83
List Price:  zł315.71
You save:  zł157.87
Already have an account? Log In

Transcript

Another way to run your JavaScript code is by using the terminal or Cmd in Windows. So here, I'm going to search for the Terminal Terminal. And I'm going to open the terminal. And once you open the terminal, you need to get to the location where your your JavaScript file is. So my JavaScript file, as you can see, is on my desk is on my desktop. So here I'm going to use CD to change directory and then desktop and hit Enter.

And as you can see, I have changed the current directory of my terminal to the desktop. Now what you need to do is you need to type Knight and then JavaScript the name of the file here my my file name is JavaScript dot j s. So we need to type that here. Java Script dot j s If your file name is different, just just add the file name, dot j s, of course, after you type note, and then hit enter. And as you can see, this is test has been printed, because once you hit enter, it's going to execute what is inside that file. What is inside our file is this is a test. So this is a second way of running our JavaScript code, but we are not going to use this.

The the one of the methods that we are going to use most of the time is this one, because this, this one is much easier. Once you save and build, it's going to run your program in your console instead of just going each time to the to the terminal to run your code. And if you are a Windows user, just use the CMD in Windows and do the same exact thing. Just go to the location where your your file is And then type node and then the name of the file. And then finally, dot j s like this. And then hit enter, it's going to print out or it's going to execute the code inside your file.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.