doc: add node: prefix for all core modules

Some core modules can be loaded with or without the `node:` prefix.
Using the prefix disambiguates which specifiers refer to core modules.

This commit updates the docs to use the prefix everywhere a core module
is referenced.

PR-URL: https://github.com/nodejs/node/pull/42752
Fixes: https://github.com/nodejs/node/issues/38343
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
This commit is contained in:
Antoine du Hamel authored and Michaël Zasso committed 2022-07-31 09:44:40 +02:00
1 parent 29976a356b
commit cc398a829b
58 files changed
+1640 -1632

No files matched your search

+13 -13
View File
@@ -12,8 +12,8 @@ separate module.
## Determining if crypto support is unavailable
It is possible for Node.js to be built without including support for the
`crypto` module. In such cases, attempting to `import` from `https` or
calling `require('https')` will result in an error being thrown.
`node:crypto` module. In such cases, attempting to `import` from `https` or
calling `require('node:https')` will result in an error being thrown.
When using CommonJS, the error thrown can be caught using try/catch:
@@ -22,7 +22,7 @@ When using CommonJS, the error thrown can be caught using try/catch:
```cjs
let https;
try {
https = require('https');
https = require('node:https');
} catch (err) {
console.log('https support is disabled!');
}
@@ -40,7 +40,7 @@ of Node.js where crypto support is not enabled, consider using the
```mjs
let https;
try {
https = await import('https');
https = await import('node:https');
} catch (err) {
console.log('https support is disabled!');
}
@@ -215,8 +215,8 @@ added: v0.3.4
```js
// curl -k https://localhost:8000/
const https = require('https');
const fs = require('fs');
const https = require('node:https');
const fs = require('node:fs');
const options = {
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
@@ -232,8 +232,8 @@ https.createServer(options, (req, res) => {
Or
```js
const https = require('https');
const fs = require('fs');
const https = require('node:https');
const fs = require('node:fs');
const options = {
pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
@@ -274,7 +274,7 @@ string, it is automatically parsed with [`new URL()`][]. If it is a [`URL`][]
object, it will be automatically converted to an ordinary `options` object.
```js
const https = require('https');
const https = require('node:https');
https.get('https://encrypted.google.com/', (res) => {
console.log('statusCode:', res.statusCode);
@@ -351,7 +351,7 @@ class. The `ClientRequest` instance is a writable stream. If one needs to
upload a file with a POST request, then write to the `ClientRequest` object.
```js
const https = require('https');
const https = require('node:https');
const options = {
hostname: 'encrypted.google.com',
@@ -425,9 +425,9 @@ Example pinning on certificate fingerprint, or the public key (similar to
`pin-sha256`):
```js
const tls = require('tls');
const https = require('https');
const crypto = require('crypto');
const tls = require('node:tls');
const https = require('node:https');
const crypto = require('node:crypto');
function sha256(s) {
return crypto.createHash('sha256').update(s).digest('base64');