Skip to content

Commit cf5f25f

Browse files
chore(learn): small update (#6132)
* chore(learn): small update * update grammar * add référence to Learn section * update about to have same code as learn * update from feedback * rewrite: "Restart the application automatically" * Update pages/en/learn/command-line/how-to-read-environment-variables-from-nodejs.md Co-authored-by: Brian Muenzenmeyer <[email protected]> Signed-off-by: Augustin Mauroy <[email protected]> * Update pages/en/learn/command-line/output-to-the-command-line-using-nodejs.md Co-authored-by: Brian Muenzenmeyer <[email protected]> Signed-off-by: Augustin Mauroy <[email protected]> * Update run-nodejs-scripts-from-the-command-line.md * Update pages/en/learn/command-line/run-nodejs-scripts-from-the-command-line.md Signed-off-by: Brian Muenzenmeyer <[email protected]> --------- Signed-off-by: Augustin Mauroy <[email protected]> Signed-off-by: Brian Muenzenmeyer <[email protected]> Co-authored-by: Brian Muenzenmeyer <[email protected]>
1 parent db7f2e6 commit cf5f25f

19 files changed

+57
-60
lines changed

pages/en/about/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ connections can be handled concurrently. Upon each connection, the callback is
1111
fired, but if there is no work to be done, Node.js will sleep.
1212

1313
```js
14-
const http = require('http');
14+
const http = require('node:http');
1515

1616
const hostname = '127.0.0.1';
1717
const port = 3000;

pages/en/get-involved/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ layout: contribute.hbs
1818

1919
## Learning
2020

21-
- [Official API reference documentation](https://nodejs.org/api/) details the Node.js API.
21+
- [Official Learn section](https://nodejs.org/en/learn/) of the Node.js website.
22+
- [Official API reference documentation](https://nodejs.org/api/).
2223
- [NodeSchool.io](https://nodeschool.io/) will teach you Node.js concepts via interactive command-line games.
2324
- [Stack Overflow Node.js tag](https://stackoverflow.com/questions/tagged/node.js) collects new information every day.
2425
- [The DEV Community Node.js tag](https://dev.to/t/node) is a place to share Node.js projects, articles and tutorials as well as start discussions and ask for feedback on Node.js-related topics. Developers of all skill-levels are welcome to take part.

pages/en/learn/asynchronous-work/javascript-asynchronous-programming-and-callbacks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ How do you handle errors with callbacks? One very common strategy is to use what
9393
If there is no error, the object is `null`. If there is an error, it contains some description of the error and other information.
9494

9595
```js
96-
const fs = require('fs');
96+
const fs = require('node:fs');
9797

9898
fs.readFile('/file.json', (err, data) => {
9999
if (err) {

pages/en/learn/asynchronous-work/overview-of-blocking-vs-non-blocking.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ execute **asynchronously**.
4040
Using the File System module as an example, this is a **synchronous** file read:
4141

4242
```js
43-
const fs = require('fs');
43+
const fs = require('node:fs');
4444

4545
const data = fs.readFileSync('/file.md'); // blocks here until file is read
4646
```
4747

4848
And here is an equivalent **asynchronous** example:
4949

5050
```js
51-
const fs = require('fs');
51+
const fs = require('node:fs');
5252

5353
fs.readFile('/file.md', (err, data) => {
5454
if (err) throw err;
@@ -65,7 +65,7 @@ shown.
6565
Let's expand our example a little bit:
6666

6767
```js
68-
const fs = require('fs');
68+
const fs = require('node:fs');
6969

7070
const data = fs.readFileSync('/file.md'); // blocks here until file is read
7171
console.log(data);
@@ -75,7 +75,7 @@ moreWork(); // will run after console.log
7575
And here is a similar, but not equivalent asynchronous example:
7676

7777
```js
78-
const fs = require('fs');
78+
const fs = require('node:fs');
7979

8080
fs.readFile('/file.md', (err, data) => {
8181
if (err) throw err;
@@ -114,7 +114,7 @@ There are some patterns that should be avoided when dealing with I/O. Let's look
114114
at an example:
115115

116116
```js
117-
const fs = require('fs');
117+
const fs = require('node:fs');
118118

119119
fs.readFile('/file.md', (err, data) => {
120120
if (err) throw err;
@@ -129,7 +129,7 @@ better way to write this, which is completely **non-blocking** and guaranteed to
129129
execute in the correct order is:
130130

131131
```js
132-
const fs = require('fs');
132+
const fs = require('node:fs');
133133

134134
fs.readFile('/file.md', (readFileErr, data) => {
135135
if (readFileErr) throw readFileErr;

pages/en/learn/asynchronous-work/the-nodejs-event-emitter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This module, in particular, offers the `EventEmitter` class, which we'll use to
1515
You initialize that using
1616

1717
```js
18-
const EventEmitter = require('events');
18+
const EventEmitter = require('node:events');
1919

2020
const eventEmitter = new EventEmitter();
2121
```

pages/en/learn/asynchronous-work/understanding-processnexttick.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ process.nextTick(() => {
4747
```bash
4848
Hello => number 1
4949
Running at next tick => number 2
50-
Running before the timeout => number 3
5150
The timeout running last => number 4
51+
Running before the timeout => number 3
5252
```

pages/en/learn/command-line/accept-input-from-the-command-line-in-nodejs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ How to make a Node.js CLI program interactive?
1111
Node.js since version 7 provides the [`readline` module](https://nodejs.org/api/readline.html) to perform exactly this: get input from a readable stream such as the `process.stdin` stream, which during the execution of a Node.js program is the terminal input, one line at a time.
1212

1313
```js
14-
const readline = require('readline').createInterface({
14+
const readline = require('node:readline').createInterface({
1515
input: process.stdin,
1616
output: process.stdout,
1717
});

pages/en/learn/command-line/how-to-read-environment-variables-from-nodejs.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ process.env.NODE_ENV; // "development"
4747
```
4848

4949
> You can also run your js file with `node -r dotenv/config index.js` command if you don't want to import the package in your code.
50+
51+
> Note: Node.js 20 introduced **experimental** [support for .env files](https://nodejs.org/dist/latest-v20.x/docs/api/cli.html#--env-fileconfig).

pages/en/learn/command-line/how-to-use-the-nodejs-repl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ If you type `.break` at the end of a line, the multiline mode will stop and the
113113
We can import the REPL in a JavaScript file using `repl`.
114114

115115
```js
116-
const repl = require('repl');
116+
const repl = require('node:repl');
117117
```
118118

119119
Using the repl variable we can perform various operations.

pages/en/learn/command-line/output-to-the-command-line-using-nodejs.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ You can just count apples and oranges:
8080
```js
8181
const oranges = ['orange', 'orange'];
8282
const apples = ['just one apple'];
83+
8384
oranges.forEach(fruit => {
8485
console.count(fruit);
8586
});
@@ -97,6 +98,7 @@ We will use the apples and orange example to demonstrate this.
9798
```js
9899
const oranges = ['orange', 'orange'];
99100
const apples = ['just one apple'];
101+
100102
oranges.forEach(fruit => {
101103
console.count(fruit);
102104
});
@@ -178,7 +180,7 @@ You can try that in the Node.js REPL, and it will print `hi!` in yellow.
178180

179181
However, this is the low-level way to do this. The simplest way to go about coloring the console output is by using a library. [Chalk](https://github.com/chalk/chalk) is such a library, and in addition to coloring it also helps with other styling facilities, like making text bold, italic or underlined.
180182

181-
You install it with `npm install chalk@4`, then you can use it:
183+
You install it with `npm install chalk`, then you can use it:
182184

183185
```js
184186
const chalk = require('chalk');

0 commit comments

Comments
 (0)