5
5
6
6
` node [options] [V8 options] [script.js | -e "script" | - ] [arguments] `
7
7
8
- Please see the [ Command Line Options] [ ] document for information about
9
- different options and ways to run scripts with Node.js.
8
+ Please see the [ Command Line Options] [ ] document for more information.
10
9
11
10
## Example
12
11
An example of a [ web server] [ ] written with Node.js which responds with
13
12
` 'Hello, World!' ` :
14
13
15
- Commands displayed in this document are shown starting with ` $ ` or ` > `
16
- to replicate how they would appear in a user's terminal.
17
- Do not include the ` $ ` and ` > ` characters. They are there to
18
- indicate the start of each command.
14
+ Commands in this document start with ` $ ` or ` > ` to replicate how they would
15
+ appear in a user's terminal. Do not include the ` $ ` and ` > ` characters. They are
16
+ there to show the start of each command.
19
17
20
- There are many tutorials and examples that follow this
21
- convention: ` $ ` or ` > ` for commands run as a regular user, and ` # `
22
- for commands that should be executed as an administrator.
18
+ Lines that don’t start with ` $ ` or ` > ` character show the output of the previous
19
+ command.
23
20
24
- Lines that don’t start with ` $ ` or ` > ` character are typically showing
25
- the output of the previous command.
26
-
27
- Firstly, make sure to have downloaded and installed Node.js.
28
- See [ this guide] [ ] for further install information.
21
+ First, make sure to have downloaded and installed Node.js. See [ this guide] [ ]
22
+ for further install information.
29
23
30
24
Now, create an empty project folder called ` projects ` , then navigate into it.
31
- The project folder can be named based on the user's current project title, but
32
- this example will use ` projects ` as the project folder.
33
25
34
26
Linux and Mac:
35
27
@@ -75,14 +67,13 @@ server.listen(port, hostname, () => {
75
67
});
76
68
```
77
69
78
- Save the file, go back to the terminal window enter the following command:
70
+ Save the file, go back to the terminal window, and enter the following command:
79
71
80
72
``` console
81
73
$ node hello-world.js
82
74
```
83
75
84
- An output like this should appear in the terminal to indicate Node.js
85
- server is running:
76
+ Output like this should appear in the terminal:
86
77
87
78
``` console
88
79
Server running at http://127.0.0.1:3000/
@@ -93,8 +84,6 @@ Now, open any preferred web browser and visit `http://127.0.0.1:3000`.
93
84
If the browser displays the string ` Hello, World! ` , that indicates
94
85
the server is working.
95
86
96
- Many of the examples in the documentation can be run similarly.
97
-
98
87
[ Command Line Options ] : cli.html#cli_command_line_options
99
88
[ this guide ] : https://nodejs.org/en/download/package-manager/
100
89
[ web server ] : http.html
0 commit comments