Repository: pinojs/pino
Pull request #2003 (2024-07-10 22:37:32)

chore: use node: imports
(available since node 14.18)

jsumners: I'm not clear what this offers. Will it result in issues from people bundling things?
Cangit: There have been quite some discussions on the nodejs repo when the feature was introduced. Recently added modules don't have unprefixed versions available, like `node:sqlite` and `node:test`. [Nodejs recommends](https://github.com/nodejs/node/issues/38343) the `node:` syntax for requiring core modules in the docs. [Modern linters like biomejs have it on by default](https://biomejs.dev/linter/rules/use-nodejs-import-protocol/). It supports a more extensive standard library in JavaScript. It makes it clear for beginners that you are adding a Node.js builtin module. There are some microscopic cache(skip) benefits and security benefits.

If you are worried about deno and bun support (don't know if pino runs as is currently?) they handle the `node:` syntax fine. My understanding is that pinojs v9 only supports nodejs >=18, so its not breaking in that regard either.

Disclaimer: I am fully aware all of these reasons are opinionated and none are hard hitting. I do however feel obliged to suggest whatever nodejs proper/core brings out to help move the ecosystem forward.
jsumners: Yes, all of that is true. I am asking what benefit it provides this code base. Any usage of modules that require the prefix will, of course, utilize the prefix. We know that people run this dependency, `pino`, through bundlers. So the big question is: will these changes cause issues with those things and result in complaints here?

Patch:
diff --git a/benchmarks/basic.bench.js b/benchmarks/basic.bench.js
index 9fd597f..a1e27d4 100644
--- a/benchmarks/basic.bench.js
+++ b/benchmarks/basic.bench.js
@@ -5,7 +5,7 @@ const pino = require('../')
 const bunyan = require('bunyan')
 const bole = require('bole')('bench')
 const winston = require('winston')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const loglevel = require('./utils/wrap-log-level')(dest)
 const plogNodeStream = pino(dest)
diff --git a/benchmarks/child-child.bench.js b/benchmarks/child-child.bench.js
index 1d737bf..05da997 100644
--- a/benchmarks/child-child.bench.js
+++ b/benchmarks/child-child.bench.js
@@ -3,7 +3,7 @@
 const bench = require('fastbench')
 const pino = require('../')
 const bunyan = require('bunyan')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plogNodeStream = pino(dest).child({ a: 'property' }).child({ sub: 'child' })
 delete require.cache[require.resolve('../')]
diff --git a/benchmarks/child-creation.bench.js b/benchmarks/child-creation.bench.js
index 97d2c00..fe6825e 100644
--- a/benchmarks/child-creation.bench.js
+++ b/benchmarks/child-creation.bench.js
@@ -4,7 +4,7 @@ const bench = require('fastbench')
 const pino = require('../')
 const bunyan = require('bunyan')
 const bole = require('bole')('bench')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plogNodeStream = pino(dest)
 const plogDest = pino(pino.destination(('/dev/null')))
diff --git a/benchmarks/child.bench.js b/benchmarks/child.bench.js
index 0d50bc9..efe2d66 100644
--- a/benchmarks/child.bench.js
+++ b/benchmarks/child.bench.js
@@ -4,7 +4,7 @@ const bench = require('fastbench')
 const pino = require('../')
 const bunyan = require('bunyan')
 const bole = require('bole')('bench')('child')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plogNodeStream = pino(dest).child({ a: 'property' })
 delete require.cache[require.resolve('../')]
diff --git a/benchmarks/deep-object.bench.js b/benchmarks/deep-object.bench.js
index a313475..44f6c34 100644
--- a/benchmarks/deep-object.bench.js
+++ b/benchmarks/deep-object.bench.js
@@ -5,7 +5,7 @@ const pino = require('../')
 const bunyan = require('bunyan')
 const bole = require('bole')('bench')
 const winston = require('winston')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plogNodeStream = pino(dest)
 delete require.cache[require.resolve('../')]
diff --git a/benchmarks/internal/just-pino-heavy.bench.js b/benchmarks/internal/just-pino-heavy.bench.js
index 12cde81..55efc85 100644
--- a/benchmarks/internal/just-pino-heavy.bench.js
+++ b/benchmarks/internal/just-pino-heavy.bench.js
@@ -2,7 +2,7 @@
 
 const bench = require('fastbench')
 const pino = require('../../')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plog = pino(dest)
 delete require.cache[require.resolve('../../')]
diff --git a/benchmarks/internal/just-pino.bench.js b/benchmarks/internal/just-pino.bench.js
index aef06a3..04bbe23 100644
--- a/benchmarks/internal/just-pino.bench.js
+++ b/benchmarks/internal/just-pino.bench.js
@@ -2,7 +2,7 @@
 
 const bench = require('fastbench')
 const pino = require('../../')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plog = pino(dest)
 delete require.cache[require.resolve('../../')]
diff --git a/benchmarks/internal/redact.bench.js b/benchmarks/internal/redact.bench.js
index 7ba32fe..852dd75 100644
--- a/benchmarks/internal/redact.bench.js
+++ b/benchmarks/internal/redact.bench.js
@@ -2,7 +2,7 @@
 
 const bench = require('fastbench')
 const pino = require('../../')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plog = pino(dest)
 delete require.cache[require.resolve('../../')]
diff --git a/benchmarks/long-string.bench.js b/benchmarks/long-string.bench.js
index 6747b72..7f37a32 100644
--- a/benchmarks/long-string.bench.js
+++ b/benchmarks/long-string.bench.js
@@ -5,7 +5,7 @@ const pino = require('../')
 const bunyan = require('bunyan')
 const bole = require('bole')('bench')
 const winston = require('winston')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plogNodeStream = pino(dest)
 delete require.cache[require.resolve('../')]
diff --git a/benchmarks/multi-arg.bench.js b/benchmarks/multi-arg.bench.js
index 0c7af66..8cbc4dc 100644
--- a/benchmarks/multi-arg.bench.js
+++ b/benchmarks/multi-arg.bench.js
@@ -5,7 +5,7 @@ const pino = require('../')
 const bunyan = require('bunyan')
 const bole = require('bole')('bench')
 const winston = require('winston')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plogNodeStream = pino(dest)
 delete require.cache[require.resolve('../')]
diff --git a/benchmarks/multistream.js b/benchmarks/multistream.js
index d67b7e2..18b9661 100644
--- a/benchmarks/multistream.js
+++ b/benchmarks/multistream.js
@@ -3,7 +3,7 @@
 const bench = require('fastbench')
 const bunyan = require('bunyan')
 const pino = require('../')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 
 const tenStreams = [
diff --git a/benchmarks/object.bench.js b/benchmarks/object.bench.js
index 3d75582..6207dec 100644
--- a/benchmarks/object.bench.js
+++ b/benchmarks/object.bench.js
@@ -5,7 +5,7 @@ const pino = require('../')
 const bunyan = require('bunyan')
 const bole = require('bole')('bench')
 const winston = require('winston')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const loglevel = require('./utils/wrap-log-level')(dest)
 const plogNodeStream = pino(dest)
diff --git a/benchmarks/utils/generate-benchmark-doc.js b/benchmarks/utils/generate-benchmark-doc.js
index 44bd5d8..edf8a03 100644
--- a/benchmarks/utils/generate-benchmark-doc.js
+++ b/benchmarks/utils/generate-benchmark-doc.js
@@ -1,6 +1,6 @@
 'use strict'
-const { join } = require('path')
-const { execSync } = require('child_process')
+const { join } = require('node:path')
+const { execSync } = require('node:child_process')
 
 const run = (type) => {
   process.stderr.write(`benchmarking ${type}\n`)
diff --git a/benchmarks/utils/runbench.js b/benchmarks/utils/runbench.js
index 5ae9111..7bb5585 100644
--- a/benchmarks/utils/runbench.js
+++ b/benchmarks/utils/runbench.js
@@ -1,8 +1,8 @@
 'use strict'
 
-const { type, platform, arch, release, cpus } = require('os')
-const { resolve, join } = require('path')
-const spawn = require('child_process').spawn
+const { type, platform, arch, release, cpus } = require('node:os')
+const { resolve, join } = require('node:path')
+const spawn = require('node:child_process').spawn
 const pump = require('pump')
 const split = require('split2')
 const through = require('through2')
diff --git a/benchmarks/utils/wrap-log-level.js b/benchmarks/utils/wrap-log-level.js
index f144b68..77d0691 100644
--- a/benchmarks/utils/wrap-log-level.js
+++ b/benchmarks/utils/wrap-log-level.js
@@ -1,8 +1,8 @@
 'use strict'
 
-const { readFileSync } = require('fs')
+const { readFileSync } = require('node:fs')
 const vm = require('vm')
-const { join } = require('path')
+const { join } = require('node:path')
 const code = readFileSync(
   join(__dirname, '..', '..', 'node_modules', 'loglevel', 'lib', 'loglevel.js')
 )
diff --git a/browser.js b/browser.js
index f65ad76..181eaa7 100644
--- a/browser.js
+++ b/browser.js
@@ -112,7 +112,8 @@ function pino (opts) {
     formatters: opts.browser.formatters,
     levels,
     timestamp: getTimeFunction(opts),
-    messageKey: opts.messageKey || 'msg'
+    messageKey: opts.messageKey || 'msg',
+    onChild: opts.onChild || noop
   }
   logger.levels = getLevels(opts)
   logger.level = level
@@ -127,7 +128,7 @@ function pino (opts) {
   logger.serializers = serializers
   logger._serialize = serialize
   logger._stdErrSerialize = stdErrSerialize
-  logger.child = child
+  logger.child = function (...args) { return child.call(this, setOpts, ...args) }
 
   if (transmit) logger._logEvent = createLogEventShape()
 
@@ -156,7 +157,7 @@ function pino (opts) {
     })
   }
 
-  function child (bindings, childOptions) {
+  function child (setOpts, bindings, childOptions) {
     if (!bindings) {
       throw new Error('missing bindings for child Pino')
     }
@@ -194,8 +195,10 @@ function pino (opts) {
 
     // must happen before the level is assigned
     appendChildLogger(this, newLogger)
+    newLogger.child = function (...args) { return child.call(this, setOpts, ...args) }
     // required to actually initialize the logger functions for any given child
     newLogger.level = childOptions.level || this.level // allow level to be set by childOptions
+    setOpts.onChild(newLogger)
 
     return newLogger
   }
diff --git a/build/sync-version.js b/build/sync-version.js
index dc7b75a..1164cc4 100644
--- a/build/sync-version.js
+++ b/build/sync-version.js
@@ -1,5 +1,5 @@
-const fs = require('fs')
-const path = require('path')
+const fs = require('node:fs')
+const path = require('node:path')
 const { version } = require('../package.json')
 
 const metaContent = `'use strict'
diff --git a/docs/api.md b/docs/api.md
index 80fa249..b3d5a0b 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -1312,7 +1312,7 @@ Create a stream composed by multiple destination streams and returns an
 object implementing the [MultiStreamRes](#multistreamres) interface.
 
 ```js
-var fs = require('fs')
+var fs = require('node:fs')
 var pino = require('pino')
 var pretty = require('pino-pretty')
 var streams = [
diff --git a/docs/help.md b/docs/help.md
index fb111fa..383f888 100644
--- a/docs/help.md
+++ b/docs/help.md
@@ -60,7 +60,7 @@ somewhere so the log rotation tool knows where to send the signal.
 
 ```js
 // write the process pid to a well known location for later
-const fs = require('fs')
+const fs = require('node:fs')
 fs.writeFileSync('/var/run/myapp.pid', process.pid)
 
 const dest = pino.destination('/log/file')
diff --git a/docs/transports.md b/docs/transports.md
index 07f47cf..597047c 100644
--- a/docs/transports.md
+++ b/docs/transports.md
@@ -25,7 +25,7 @@ flushed as quickly as possible (there is nothing to do).
 A transport is a module that exports a default function that returns a writable stream:
 
 ```js
-import { createWriteStream } from 'fs'
+import { createWriteStream } from 'node:fs'
 
 export default (options) => {
   return createWriteStream(options.destination)
@@ -54,7 +54,7 @@ The exported function can also be async. If we use an async function we can thro
 if the transform could not be opened. As an example:
 
 ```js
-import fs from 'fs'
+import fs from 'node:fs'
 import { once } from 'events'
 export default async (options) => {
   const stream = fs.createWriteStream(options.destination)
@@ -218,7 +218,7 @@ As an example, the following transport returns a `Transform` stream:
 
 ```js
 import build from 'pino-abstract-transport'
-import { pipeline, Transform } from 'stream'
+import { pipeline, Transform } from 'node:stream'
 export default async function (options) {
   return build(function (source) {
     const myTransportStream = new Transform({
@@ -378,7 +378,7 @@ A legacy Pino "transport" is a supplementary tool that consumes Pino logs.
 Consider the following example for creating a transport:
 
 ```js
-const { pipeline, Writable } = require('stream')
+const { pipeline, Writable } = require('node:stream')
 const split = require('split2')
 
 const myTransportStream = new Writable({
diff --git a/examples/transport.js b/examples/transport.js
index 7fe71d4..7ffab98 100644
--- a/examples/transport.js
+++ b/examples/transport.js
@@ -1,8 +1,8 @@
 'use strict'
 
 const pino = require('..')
-const { tmpdir } = require('os')
-const { join } = require('path')
+const { tmpdir } = require('node:os')
+const { join } = require('node:path')
 
 const file = join(tmpdir(), `pino-${process.pid}-example`)
 
diff --git a/file.js b/file.js
index ed9d86f..7e1192b 100644
--- a/file.js
+++ b/file.js
@@ -1,7 +1,7 @@
 'use strict'
 
 const pino = require('./pino')
-const { once } = require('events')
+const { once } = require('node:events')
 
 module.exports = async function (opts = {}) {
   const destOpts = Object.assign({}, opts, { dest: opts.destination || 1, sync: false })
diff --git a/lib/proto.js b/lib/proto.js
index b82fd0c..ef49a71 100644
--- a/lib/proto.js
+++ b/lib/proto.js
@@ -2,7 +2,7 @@
 
 /* eslint no-prototype-builtins: 0 */
 
-const { EventEmitter } = require('events')
+const { EventEmitter } = require('node:events')
 const {
   lsCacheSym,
   levelValSym,
diff --git a/lib/transport-stream.js b/lib/transport-stream.js
index 91671cc..d1f1fd1 100644
--- a/lib/transport-stream.js
+++ b/lib/transport-stream.js
@@ -7,7 +7,7 @@ module.exports = loadTransportStreamBuilder
 /**
  * Loads & returns a function to build transport streams
  * @param {string} target
- * @returns {function(object): Promise<import('stream').Writable>}
+ * @returns {function(object): Promise<import('node:stream').Writable>}
  * @throws {Error} In case the target module does not export a function
  */
 async function loadTransportStreamBuilder (target) {
diff --git a/lib/transport.js b/lib/transport.js
index 8ecd219..e768d35 100644
--- a/lib/transport.js
+++ b/lib/transport.js
@@ -2,7 +2,7 @@
 
 const { createRequire } = require('module')
 const getCallers = require('./caller')
-const { join, isAbsolute, sep } = require('path')
+const { join, isAbsolute, sep } = require('node:path')
 const sleep = require('atomic-sleep')
 const onExit = require('on-exit-leak-free')
 const ThreadStream = require('thread-stream')
diff --git a/lib/worker.js b/lib/worker.js
index dcbd5d3..0bc035a 100644
--- a/lib/worker.js
+++ b/lib/worker.js
@@ -1,7 +1,7 @@
 'use strict'
 
-const EE = require('events')
-const { pipeline, PassThrough } = require('stream')
+const EE = require('node:events')
+const { pipeline, PassThrough } = require('node:stream')
 const pino = require('../pino.js')
 const build = require('pino-abstract-transport')
 const loadTransportStreamBuilder = require('./transport-stream')
diff --git a/pino.js b/pino.js
index b2ec4dd..740b97d 100644
--- a/pino.js
+++ b/pino.js
@@ -1,6 +1,6 @@
 'use strict'
-/* eslint no-prototype-builtins: 0 */
-const os = require('os')
+
+const os = require('node:os')
 const stdSerializers = require('pino-std-serializers')
 const caller = require('./lib/caller')
 const redaction = require('./lib/redaction')


Test patch:
diff --git a/test/basic.test.js b/test/basic.test.js
index cbe0aa3..6689343 100644
--- a/test/basic.test.js
+++ b/test/basic.test.js
@@ -1,6 +1,6 @@
 'use strict'
-const os = require('os')
-const { readFileSync } = require('fs')
+const os = require('node:os')
+const { readFileSync } = require('node:fs')
 const { test } = require('tap')
 const { sink, check, once, watchFileCreated, file } = require('./helper')
 const pino = require('../')
diff --git a/test/broken-pipe.test.js b/test/broken-pipe.test.js
index a5d8611..4ec2594 100644
--- a/test/broken-pipe.test.js
+++ b/test/broken-pipe.test.js
@@ -1,8 +1,8 @@
 'use strict'
 
 const t = require('tap')
-const { join } = require('path')
-const { fork } = require('child_process')
+const { join } = require('node:path')
+const { fork } = require('node:child_process')
 const { once } = require('./helper')
 const pino = require('..')
 
diff --git a/test/browser-child.test.js b/test/browser-child.test.js
index db80e7e..679261a 100644
--- a/test/browser-child.test.js
+++ b/test/browser-child.test.js
@@ -106,6 +106,20 @@ test('changing child log level should not affect parent log behavior', ({ end, s
   end()
 })
 
+test('onChild callback should be called when new child is created', ({ end, pass, plan }) => {
+  plan(1)
+  const instance = pino({
+    level: 'error',
+    browser: {},
+    onChild: (_child) => {
+      pass('onChild callback was called')
+      end()
+    }
+  })
+
+  instance.child({})
+})
+
 function checkLogObjects (is, same, actual, expected) {
   is(actual.time <= Date.now(), true, 'time is greater than Date.now()')
 
diff --git a/test/complex-objects.test.js b/test/complex-objects.test.js
index e647ffe..c0940f6 100644
--- a/test/complex-objects.test.js
+++ b/test/complex-objects.test.js
@@ -2,7 +2,7 @@
 
 const { test } = require('tap')
 const { sink, once } = require('./helper')
-const { PassThrough } = require('stream')
+const { PassThrough } = require('node:stream')
 const pino = require('../')
 
 test('Proxy and stream objects', async ({ equal }) => {
diff --git a/test/error.test.js b/test/error.test.js
index 01be0f4..e4570fa 100644
--- a/test/error.test.js
+++ b/test/error.test.js
@@ -2,7 +2,7 @@
 
 /* eslint no-prototype-builtins: 0 */
 
-const os = require('os')
+const os = require('node:os')
 const { test } = require('tap')
 const { sink, once } = require('./helper')
 const pino = require('../')
diff --git a/test/escaping.test.js b/test/escaping.test.js
index 1c80d83..de5b34e 100644
--- a/test/escaping.test.js
+++ b/test/escaping.test.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const os = require('os')
+const os = require('node:os')
 const { test } = require('tap')
 const { sink, once } = require('./helper')
 const pino = require('../')
diff --git a/test/esm/named-exports.mjs b/test/esm/named-exports.mjs
index 326d34f..ee9f257 100644
--- a/test/esm/named-exports.mjs
+++ b/test/esm/named-exports.mjs
@@ -1,9 +1,8 @@
-import { tmpdir, hostname } from 'os'
+import { hostname } from 'node:os'
 import t from 'tap'
 import { sink, check, once, watchFileCreated, file } from '../helper.js'
 import { pino, destination } from '../../pino.js'
-import { join } from 'path'
-import { readFileSync } from 'fs'
+import { readFileSync } from 'node:fs'
 
 t.test('named exports support', async ({ equal }) => {
   const stream = sink()
diff --git a/test/exit.test.js b/test/exit.test.js
index b373ddb..a2dcf05 100644
--- a/test/exit.test.js
+++ b/test/exit.test.js
@@ -1,7 +1,7 @@
 'use strict'
 
 const { test } = require('tap')
-const { join } = require('path')
+const { join } = require('node:path')
 const execa = require('execa')
 const writer = require('flush-write-stream')
 const { once } = require('./helper')
diff --git a/test/fixtures/broken-pipe/basic.js b/test/fixtures/broken-pipe/basic.js
index def7cd0..cc33c9b 100644
--- a/test/fixtures/broken-pipe/basic.js
+++ b/test/fixtures/broken-pipe/basic.js
@@ -2,7 +2,7 @@
 
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 
 const pino = require('../../..')()
 
diff --git a/test/fixtures/broken-pipe/destination.js b/test/fixtures/broken-pipe/destination.js
index 15a8102..701f686 100644
--- a/test/fixtures/broken-pipe/destination.js
+++ b/test/fixtures/broken-pipe/destination.js
@@ -2,7 +2,7 @@
 
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 
 const pino = require('../../..')
 const logger = pino(pino.destination())
diff --git a/test/fixtures/broken-pipe/syncfalse.js b/test/fixtures/broken-pipe/syncfalse.js
index 428f4ae..de71431 100644
--- a/test/fixtures/broken-pipe/syncfalse.js
+++ b/test/fixtures/broken-pipe/syncfalse.js
@@ -2,7 +2,7 @@
 
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 
 const pino = require('../../..')
 const logger = pino(pino.destination({ sync: false }))
diff --git a/test/fixtures/console-transport.js b/test/fixtures/console-transport.js
index d2c95b7..9974ebc 100644
--- a/test/fixtures/console-transport.js
+++ b/test/fixtures/console-transport.js
@@ -1,4 +1,4 @@
-const { Writable } = require('stream')
+const { Writable } = require('node:stream')
 
 module.exports = (options) => {
   const myTransportStream = new Writable({
diff --git a/test/fixtures/default-exit.js b/test/fixtures/default-exit.js
index a8a5aec..3fd2a0e 100644
--- a/test/fixtures/default-exit.js
+++ b/test/fixtures/default-exit.js
@@ -1,6 +1,6 @@
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('./../../'))
 const logger = pino()
 logger.info('hello')
diff --git a/test/fixtures/destination-exit.js b/test/fixtures/destination-exit.js
index 5cfea74..63c6d69 100644
--- a/test/fixtures/destination-exit.js
+++ b/test/fixtures/destination-exit.js
@@ -1,6 +1,6 @@
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('./../../'))
 const logger = pino({}, pino.destination(1))
 logger.info('hello')
diff --git a/test/fixtures/noop-transport.js b/test/fixtures/noop-transport.js
index 5e36c44..745504a 100644
--- a/test/fixtures/noop-transport.js
+++ b/test/fixtures/noop-transport.js
@@ -1,4 +1,4 @@
-const { Writable } = require('stream')
+const { Writable } = require('node:stream')
 
 module.exports = () => {
   return new Writable({
diff --git a/test/fixtures/pretty/null-prototype.js b/test/fixtures/pretty/null-prototype.js
index a74ca2c..c88e686 100644
--- a/test/fixtures/pretty/null-prototype.js
+++ b/test/fixtures/pretty/null-prototype.js
@@ -1,6 +1,6 @@
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('./../../../'))
 const log = pino({ prettyPrint: true })
 const obj = Object.create(null)
diff --git a/test/fixtures/stdout-hack-protection.js b/test/fixtures/stdout-hack-protection.js
index edf45df..525ef62 100644
--- a/test/fixtures/stdout-hack-protection.js
+++ b/test/fixtures/stdout-hack-protection.js
@@ -6,6 +6,6 @@ process.stdout.write = function (chunk) {
 }
 
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('../../'))()
 pino.info('me')
diff --git a/test/fixtures/syncfalse-child.js b/test/fixtures/syncfalse-child.js
index 269ebfd..f858b3d 100644
--- a/test/fixtures/syncfalse-child.js
+++ b/test/fixtures/syncfalse-child.js
@@ -1,6 +1,6 @@
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('./../../'))
 const asyncLogger = pino(pino.destination({ sync: false })).child({ hello: 'world' })
 asyncLogger.info('h')
diff --git a/test/fixtures/syncfalse-exit.js b/test/fixtures/syncfalse-exit.js
index d93f9f2..fb09eab 100644
--- a/test/fixtures/syncfalse-exit.js
+++ b/test/fixtures/syncfalse-exit.js
@@ -1,6 +1,6 @@
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('./../../'))
 const dest = pino.destination({ dest: 1, minLength: 4096, sync: false })
 const logger = pino({}, dest)
diff --git a/test/fixtures/syncfalse-flush-exit.js b/test/fixtures/syncfalse-flush-exit.js
index 70a2f6d..bf9cb4f 100644
--- a/test/fixtures/syncfalse-flush-exit.js
+++ b/test/fixtures/syncfalse-flush-exit.js
@@ -1,6 +1,6 @@
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('./../../'))
 const dest = pino.destination({ dest: 1, minLength: 4096, sync: false })
 const logger = pino({}, dest)
diff --git a/test/fixtures/syncfalse.js b/test/fixtures/syncfalse.js
index a111bd9..4d36752 100644
--- a/test/fixtures/syncfalse.js
+++ b/test/fixtures/syncfalse.js
@@ -1,6 +1,6 @@
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('./../../'))
 const asyncLogger = pino(pino.destination({ minLength: 4096, sync: false }))
 asyncLogger.info('h')
diff --git a/test/fixtures/to-file-transport-with-transform.js b/test/fixtures/to-file-transport-with-transform.js
index 1a07eef..89cf465 100644
--- a/test/fixtures/to-file-transport-with-transform.js
+++ b/test/fixtures/to-file-transport-with-transform.js
@@ -1,8 +1,8 @@
 'use strict'
 
-const fs = require('fs')
-const { once } = require('events')
-const { Transform } = require('stream')
+const fs = require('node:fs')
+const { once } = require('node:events')
+const { Transform } = require('node:stream')
 
 async function run (opts) {
   if (!opts.destination) throw new Error('kaboom')
diff --git a/test/fixtures/to-file-transport.js b/test/fixtures/to-file-transport.js
index 33de462..09f1274 100644
--- a/test/fixtures/to-file-transport.js
+++ b/test/fixtures/to-file-transport.js
@@ -1,7 +1,7 @@
 'use strict'
 
-const fs = require('fs')
-const { once } = require('events')
+const fs = require('node:fs')
+const { once } = require('node:events')
 
 async function run (opts) {
   if (!opts.destination) throw new Error('kaboom')
diff --git a/test/fixtures/to-file-transport.mjs b/test/fixtures/to-file-transport.mjs
index e0cbeec..4925d3b 100644
--- a/test/fixtures/to-file-transport.mjs
+++ b/test/fixtures/to-file-transport.mjs
@@ -1,5 +1,5 @@
-import { createWriteStream } from 'fs'
-import { once } from 'events'
+import { createWriteStream } from 'node:fs'
+import { once } from 'node:events'
 
 export default async function run (opts) {
   const stream = createWriteStream(opts.destination)
diff --git a/test/fixtures/transport-main.js b/test/fixtures/transport-main.js
index 858cf56..cb02005 100644
--- a/test/fixtures/transport-main.js
+++ b/test/fixtures/transport-main.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const { join } = require('path')
+const { join } = require('node:path')
 const pino = require('../..')
 const transport = pino.transport({
   target: join(__dirname, 'transport-worker.js')
diff --git a/test/fixtures/transport-transform.js b/test/fixtures/transport-transform.js
index 2ba524b..4950236 100644
--- a/test/fixtures/transport-transform.js
+++ b/test/fixtures/transport-transform.js
@@ -1,7 +1,7 @@
 'use strict'
 
 const build = require('pino-abstract-transport')
-const { pipeline, Transform } = require('stream')
+const { pipeline, Transform } = require('node:stream')
 module.exports = (options) => {
   return build(function (source) {
     const myTransportStream = new Transform({
diff --git a/test/fixtures/transport-uses-pino-config.js b/test/fixtures/transport-uses-pino-config.js
index 0490b63..0c87c94 100644
--- a/test/fixtures/transport-uses-pino-config.js
+++ b/test/fixtures/transport-uses-pino-config.js
@@ -1,7 +1,7 @@
 'use strict'
 
 const build = require('pino-abstract-transport')
-const { pipeline, Transform } = require('stream')
+const { pipeline, Transform } = require('node:stream')
 module.exports = () => {
   return build(function (source) {
     const myTransportStream = new Transform({
diff --git a/test/fixtures/transport-worker-data.js b/test/fixtures/transport-worker-data.js
index 24e3ee0..1e0e7a8 100644
--- a/test/fixtures/transport-worker-data.js
+++ b/test/fixtures/transport-worker-data.js
@@ -1,7 +1,7 @@
 'use strict'
 
 const { parentPort, workerData } = require('worker_threads')
-const { Writable } = require('stream')
+const { Writable } = require('node:stream')
 
 module.exports = (options) => {
   const myTransportStream = new Writable({
diff --git a/test/fixtures/transport-worker.js b/test/fixtures/transport-worker.js
index 16bbefc..8964b26 100644
--- a/test/fixtures/transport-worker.js
+++ b/test/fixtures/transport-worker.js
@@ -1,7 +1,7 @@
 'use strict'
 
-const { Writable } = require('stream')
-const fs = require('fs')
+const { Writable } = require('node:stream')
+const fs = require('node:fs')
 module.exports = (options) => {
   const myTransportStream = new Writable({
     autoDestroy: true,
diff --git a/test/fixtures/transport/index.js b/test/fixtures/transport/index.js
index c576a7b..f255858 100644
--- a/test/fixtures/transport/index.js
+++ b/test/fixtures/transport/index.js
@@ -1,7 +1,7 @@
 'use strict'
 
-const fs = require('fs')
-const { once } = require('events')
+const fs = require('node:fs')
+const { once } = require('node:events')
 
 async function run (opts) {
   const stream = fs.createWriteStream(opts.destination)
diff --git a/test/fixtures/ts/to-file-transport-with-transform.ts b/test/fixtures/ts/to-file-transport-with-transform.ts
index e3586a0..aa56b3d 100644
--- a/test/fixtures/ts/to-file-transport-with-transform.ts
+++ b/test/fixtures/ts/to-file-transport-with-transform.ts
@@ -1,6 +1,6 @@
-import * as fs from 'fs'
-import { once } from 'events'
-import { Transform } from 'stream'
+import * as fs from 'node:fs'
+import { once } from 'node:events'
+import { Transform } from 'node:stream'
 
 async function run (opts: {  destination?: fs.PathLike }): Promise<Transform> {
   if (!opts.destination) throw new Error('kaboom')
diff --git a/test/fixtures/ts/to-file-transport.ts b/test/fixtures/ts/to-file-transport.ts
index 6ebf09c..1860606 100644
--- a/test/fixtures/ts/to-file-transport.ts
+++ b/test/fixtures/ts/to-file-transport.ts
@@ -1,5 +1,5 @@
-import * as fs from 'fs'
-import { once } from 'events'
+import * as fs from 'node:fs'
+import { once } from 'node:events'
 
 async function run (opts: { destination?: fs.PathLike }): Promise<fs.WriteStream> {
   if (!opts.destination) throw new Error('kaboom')
diff --git a/test/fixtures/ts/transpile.cjs b/test/fixtures/ts/transpile.cjs
index 1ad61b4..6c2af67 100755
--- a/test/fixtures/ts/transpile.cjs
+++ b/test/fixtures/ts/transpile.cjs
@@ -1,7 +1,7 @@
 #!/usr/bin/env node
 
 const execa = require('execa')
-const fs = require('fs')
+const fs = require('node:fs')
 
 const existsSync = fs.existsSync
 const stat = fs.promises.stat
diff --git a/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts b/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts
index 288f0bf..f3e6f2e 100644
--- a/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts
+++ b/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts
@@ -1,5 +1,5 @@
 import pino from '../../..'
-import { join } from 'path'
+import { join } from 'node:path'
 
 const transport = pino.transport({
   target: join(__dirname, 'to-file-transport-with-transform.ts'),
diff --git a/test/fixtures/ts/transport-main.ts b/test/fixtures/ts/transport-main.ts
index fdf9914..f31f88c 100644
--- a/test/fixtures/ts/transport-main.ts
+++ b/test/fixtures/ts/transport-main.ts
@@ -1,4 +1,4 @@
-import { join } from 'path'
+import { join } from 'node:path'
 import pino from '../../..'
 
 const transport = pino.transport({
diff --git a/test/fixtures/ts/transport-worker.ts b/test/fixtures/ts/transport-worker.ts
index 7af63da..8061291 100644
--- a/test/fixtures/ts/transport-worker.ts
+++ b/test/fixtures/ts/transport-worker.ts
@@ -1,4 +1,4 @@
-import { Writable } from 'stream'
+import { Writable } from 'node:stream'
 
 export default (): Writable => {
   const myTransportStream = new Writable({
diff --git a/test/formatters.test.js b/test/formatters.test.js
index 39a0013..77ae0ef 100644
--- a/test/formatters.test.js
+++ b/test/formatters.test.js
@@ -1,9 +1,9 @@
 'use strict'
 /* eslint no-prototype-builtins: 0 */
 
-const { hostname } = require('os')
-const { join } = require('path')
-const { readFile } = require('fs').promises
+const { hostname } = require('node:os')
+const { join } = require('node:path')
+const { readFile } = require('node:fs').promises
 const { test } = require('tap')
 const { sink, once, watchFileCreated, file } = require('./helper')
 const pino = require('../')
diff --git a/test/helper.d.ts b/test/helper.d.ts
index cc10db1..5798d04 100644
--- a/test/helper.d.ts
+++ b/test/helper.d.ts
@@ -1,4 +1,4 @@
-import { PathLike } from 'fs'
+import { PathLike } from 'node:fs'
 
 export declare function watchFileCreated(filename: PathLike): Promise<void>
 export declare function watchForWrite(filename: PathLike, testString: string): Promise<void>
diff --git a/test/helper.js b/test/helper.js
index 2aca1aa..0080396 100644
--- a/test/helper.js
+++ b/test/helper.js
@@ -1,14 +1,14 @@
 'use strict'
 
 const crypto = require('crypto')
-const os = require('os')
+const os = require('node:os')
 const writer = require('flush-write-stream')
 const split = require('split2')
-const { existsSync, readFileSync, statSync, unlinkSync } = require('fs')
+const { existsSync, readFileSync, statSync, unlinkSync } = require('node:fs')
 const pid = process.pid
 const hostname = os.hostname()
 const t = require('tap')
-const { join } = require('path')
+const { join } = require('node:path')
 const { tmpdir } = os
 
 const isWin = process.platform === 'win32'
diff --git a/test/http.test.js b/test/http.test.js
index d5e01b4..650868f 100644
--- a/test/http.test.js
+++ b/test/http.test.js
@@ -1,7 +1,7 @@
 'use strict'
 
 const http = require('http')
-const os = require('os')
+const os = require('node:os')
 const semver = require('semver')
 const { test, skip } = require('tap')
 const { sink, once } = require('./helper')
diff --git a/test/internals/version.test.js b/test/internals/version.test.js
index eeeaf9d..8528891 100644
--- a/test/internals/version.test.js
+++ b/test/internals/version.test.js
@@ -1,7 +1,7 @@
 'use strict'
 
-const fs = require('fs')
-const path = require('path')
+const fs = require('node:fs')
+const path = require('node:path')
 const t = require('tap')
 const test = t.test
 const pino = require('../..')()
diff --git a/test/metadata.test.js b/test/metadata.test.js
index 1330973..5ecb984 100644
--- a/test/metadata.test.js
+++ b/test/metadata.test.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const os = require('os')
+const os = require('node:os')
 const { test } = require('tap')
 const pino = require('../')
 
diff --git a/test/mixin.test.js b/test/mixin.test.js
index 18f0736..b40b3cd 100644
--- a/test/mixin.test.js
+++ b/test/mixin.test.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const os = require('os')
+const os = require('node:os')
 const { test } = require('tap')
 const { sink, once } = require('./helper')
 const pino = require('../')
diff --git a/test/multistream.test.js b/test/multistream.test.js
index b38f24b..3d505ce 100644
--- a/test/multistream.test.js
+++ b/test/multistream.test.js
@@ -1,8 +1,8 @@
 'use strict'
 
 const writeStream = require('flush-write-stream')
-const { readFileSync } = require('fs')
-const { join } = require('path')
+const { readFileSync } = require('node:fs')
+const { join } = require('node:path')
 const test = require('tap').test
 const pino = require('../')
 const multistream = pino.multistream
diff --git a/test/pkg/index.js b/test/pkg/index.js
index 762a62f..7c247f4 100644
--- a/test/pkg/index.js
+++ b/test/pkg/index.js
@@ -1,8 +1,8 @@
 'use strict'
 
-const os = require('os')
-const { join } = require('path')
-const { readFile } = require('fs').promises
+const os = require('node:os')
+const { join } = require('node:path')
+const { readFile } = require('node:fs').promises
 const { watchFileCreated, file } = require('../helper')
 const { test } = require('tap')
 const pino = require('../../pino')
diff --git a/test/pkg/pkg.test.js b/test/pkg/pkg.test.js
index c8abcb6..bf2643a 100644
--- a/test/pkg/pkg.test.js
+++ b/test/pkg/pkg.test.js
@@ -2,11 +2,11 @@
 
 const { test } = require('tap')
 const config = require('./pkg.config.json')
-const { promisify } = require('util')
-const { unlink } = require('fs/promises')
-const { join } = require('path')
-const { platform } = require('process')
-const exec = promisify(require('child_process').exec)
+const { promisify } = require('node:util')
+const { unlink } = require('node:fs/promises')
+const { join } = require('node:path')
+const { platform } = require('node:process')
+const exec = promisify(require('node:child_process').exec)
 
 /**
  * The following regex is for tesintg the deprecation warning that is thrown by the `punycode` module.
diff --git a/test/stdout-protection.test.js b/test/stdout-protection.test.js
index c10f45c..fb42621 100644
--- a/test/stdout-protection.test.js
+++ b/test/stdout-protection.test.js
@@ -1,8 +1,8 @@
 'use strict'
 
 const { test } = require('tap')
-const { join } = require('path')
-const { fork } = require('child_process')
+const { join } = require('node:path')
+const { fork } = require('node:child_process')
 const { once } = require('./helper')
 const writer = require('flush-write-stream')
 const pino = require('..')
diff --git a/test/syncfalse.test.js b/test/syncfalse.test.js
index 9243f2f..29a4fc1 100644
--- a/test/syncfalse.test.js
+++ b/test/syncfalse.test.js
@@ -1,13 +1,10 @@
 'use strict'
 
-const os = require('os')
-const {
-  createWriteStream
-} = require('fs')
-const { readFile } = require('fs').promises
-const { join } = require('path')
+const os = require('node:os')
+const { promises: { readFile }, createWriteStream } = require('node:fs')
+const { join } = require('node:path')
 const { test } = require('tap')
-const { fork } = require('child_process')
+const { fork } = require('node:child_process')
 const writer = require('flush-write-stream')
 const {
   once,
@@ -15,7 +12,7 @@ const {
   file,
   watchFileCreated
 } = require('./helper')
-const { promisify } = require('util')
+const { promisify } = require('node:util')
 
 const sleep = promisify(setTimeout)
 
diff --git a/test/transport/big.test.js b/test/transport/big.test.js
index b732cab..d818b97 100644
--- a/test/transport/big.test.js
+++ b/test/transport/big.test.js
@@ -1,12 +1,12 @@
 'use strict'
 
 const { test } = require('tap')
-const { join } = require('path')
-const { createReadStream } = require('fs')
-const { promisify } = require('util')
+const { join } = require('node:path')
+const { createReadStream } = require('node:fs')
+const { promisify } = require('node:util')
 const execa = require('execa')
 const split = require('split2')
-const stream = require('stream')
+const stream = require('node:stream')
 const { file } = require('../helper')
 
 const pipeline = promisify(stream.pipeline)
diff --git a/test/transport/bundlers-support.test.js b/test/transport/bundlers-support.test.js
index cb10221..f651a97 100644
--- a/test/transport/bundlers-support.test.js
+++ b/test/transport/bundlers-support.test.js
@@ -1,8 +1,8 @@
 'use strict'
 
-const os = require('os')
-const { join } = require('path')
-const { readFile } = require('fs').promises
+const os = require('node:os')
+const { join } = require('node:path')
+const { readFile } = require('node:fs').promises
 const { watchFileCreated, file } = require('../helper')
 const { test } = require('tap')
 const pino = require('../../pino')
diff --git a/test/transport/caller.test.js b/test/transport/caller.test.js
index 5c55a8a..e54a786 100644
--- a/test/transport/caller.test.js
+++ b/test/transport/caller.test.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const { join } = require('path')
+const { join } = require('node:path')
 const { test } = require('tap')
 const execa = require('execa')
 
diff --git a/test/transport/core.test.js b/test/transport/core.test.js
index a61b085..44449db 100644
--- a/test/transport/core.test.js
+++ b/test/transport/core.test.js
@@ -1,9 +1,9 @@
 'use strict'
 
-const os = require('os')
-const { join } = require('path')
-const { once } = require('events')
-const { readFile, writeFile } = require('fs').promises
+const os = require('node:os')
+const { join } = require('node:path')
+const { once } = require('node:events')
+const { readFile, writeFile } = require('node:fs').promises
 const { watchFileCreated, watchForWrite, file } = require('../helper')
 const { test } = require('tap')
 const pino = require('../../')
@@ -12,7 +12,7 @@ const strip = require('strip-ansi')
 const execa = require('execa')
 const writer = require('flush-write-stream')
 const rimraf = require('rimraf')
-const { promisify } = require('util')
+const { promisify } = require('node:util')
 const { tmpdir } = os
 
 const immediate = promisify(setImmediate)
diff --git a/test/transport/core.test.ts b/test/transport/core.test.ts
index a1c80d8..deca48a 100644
--- a/test/transport/core.test.ts
+++ b/test/transport/core.test.ts
@@ -1,11 +1,11 @@
-import * as os from 'os'
-import { join } from 'path'
-import { once } from 'events'
-import fs from 'fs'
+import * as os from 'node:os'
+import { join } from 'node:path'
+import { once } from 'node:events'
+import fs from 'node:fs'
 import { watchFileCreated } from '../helper'
 import { test } from 'tap'
 import pino from '../../'
-import * as url from 'url'
+import * as url from 'node:url'
 import { default as strip } from 'strip-ansi'
 import execa from 'execa'
 import writer from 'flush-write-stream'
diff --git a/test/transport/core.transpiled.test.ts b/test/transport/core.transpiled.test.ts
index 614c258..a53b346 100644
--- a/test/transport/core.transpiled.test.ts
+++ b/test/transport/core.transpiled.test.ts
@@ -1,14 +1,10 @@
-import * as os from 'os'
-import { join } from 'path'
-import { once } from 'events'
-import fs from 'fs'
+import * as os from 'node:os'
+import { join } from 'node:path'
+import fs from 'node:fs'
 import { watchFileCreated } from '../helper'
 import { test } from 'tap'
 import pino from '../../'
-import * as url from 'url'
-import { default as strip } from 'strip-ansi'
-import execa from 'execa'
-import writer from 'flush-write-stream'
+import * as url from 'node:url'
 
 const readFile = fs.promises.readFile
 
diff --git a/test/transport/module-link.test.js b/test/transport/module-link.test.js
index 16a17fc..2210b87 100644
--- a/test/transport/module-link.test.js
+++ b/test/transport/module-link.test.js
@@ -1,11 +1,11 @@
 'use strict'
 
-const os = require('os')
-const { join } = require('path')
-const { readFile, symlink, unlink, mkdir, writeFile } = require('fs').promises
+const os = require('node:os')
+const { join } = require('node:path')
+const { readFile, symlink, unlink, mkdir, writeFile } = require('node:fs').promises
 const { test } = require('tap')
 const { isWin, isYarnPnp, watchFileCreated, file } = require('../helper')
-const { once } = require('events')
+const { once } = require('node:events')
 const execa = require('execa')
 const pino = require('../../')
 const rimraf = require('rimraf')
diff --git a/test/transport/pipeline.test.js b/test/transport/pipeline.test.js
index a845d44..c682b76 100644
--- a/test/transport/pipeline.test.js
+++ b/test/transport/pipeline.test.js
@@ -1,8 +1,8 @@
 'use strict'
 
-const os = require('os')
-const { join } = require('path')
-const { readFile } = require('fs').promises
+const os = require('node:os')
+const { join } = require('node:path')
+const { readFile } = require('node:fs').promises
 const { watchFileCreated, file } = require('../helper')
 const { test } = require('tap')
 const pino = require('../../')
diff --git a/test/transport/syncfalse.test.js b/test/transport/syncfalse.test.js
index 4b9f682..c5f7692 100644
--- a/test/transport/syncfalse.test.js
+++ b/test/transport/syncfalse.test.js
@@ -1,12 +1,12 @@
 'use strict'
 
-const os = require('os')
+const os = require('node:os')
 const pino = require('../..')
-const { join } = require('path')
+const { join } = require('node:path')
 const { test } = require('tap')
-const { readFile } = require('fs').promises
+const { readFile } = require('node:fs').promises
 const { watchFileCreated, file } = require('../helper')
-const { promisify } = require('util')
+const { promisify } = require('node:util')
 
 const { pid } = process
 const hostname = os.hostname()
diff --git a/test/transport/targets.test.js b/test/transport/targets.test.js
index 7570f15..14faa91 100644
--- a/test/transport/targets.test.js
+++ b/test/transport/targets.test.js
@@ -1,9 +1,9 @@
 'use strict'
 
 const { test } = require('tap')
-const { join } = require('path')
+const { join } = require('node:path')
 const proxyquire = require('proxyquire')
-const Writable = require('stream').Writable
+const Writable = require('node:stream').Writable
 const pino = require('../../pino')
 
 test('file-target mocked', async function ({ equal, same, plan, pass }) {
diff --git a/test/transport/uses-pino-config.test.js b/test/transport/uses-pino-config.test.js
index dc4e0f5..46f2ab3 100644
--- a/test/transport/uses-pino-config.test.js
+++ b/test/transport/uses-pino-config.test.js
@@ -1,8 +1,8 @@
 'use strict'
 
-const os = require('os')
-const { join } = require('path')
-const { readFile } = require('fs').promises
+const os = require('node:os')
+const { join } = require('node:path')
+const { readFile } = require('node:fs').promises
 const writeStream = require('flush-write-stream')
 const { watchFileCreated, file } = require('../helper')
 const { test } = require('tap')
diff --git a/test/types/pino-multistream.test-d.ts b/test/types/pino-multistream.test-d.ts
index 29f09d7..6206eca 100644
--- a/test/types/pino-multistream.test-d.ts
+++ b/test/types/pino-multistream.test-d.ts
@@ -1,6 +1,6 @@
 import { expectType } from 'tsd'
 
-import { createWriteStream } from 'fs'
+import { createWriteStream } from 'node:fs'
 
 import pino, { multistream } from '../../pino'
 
diff --git a/test/types/pino.ts b/test/types/pino.ts
index c1cf8c0..a167309 100644
--- a/test/types/pino.ts
+++ b/test/types/pino.ts
@@ -1,6 +1,6 @@
 import { StreamEntry, pino } from '../../pino'
-import { join } from 'path'
-import { tmpdir } from 'os'
+import { join } from 'node:path'
+import { tmpdir } from 'node:os'
 import pinoPretty from 'pino-pretty'
 
 const destination = join(