Skip to content

[DEP0180] DeprecationWarning: fs.Stats constructor is deprecated when using node 22 #2116

Open
@darcyrush

Description

@darcyrush

Search Terms

DeprecationWarning: fs.Stats

Steps to reproduce the problem

Warning only appears in node 22, node 21 is fine.

(node:4075381) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
    at Object.createResolve (/.../node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:146:25)
    at /.../node_modules/ts-node/src/index.ts:1494:7
    at Object.onceFn [as getNodeEsmResolver] (/.../node_modules/ts-node/src/util.ts:166:13)
    at createEsmHooks (/.../node_modules/ts-node/src/esm.ts:125:51)
    at Object.registerAndCreateEsmHooks (/.../node_modules/ts-node/src/esm.ts:118:10)
    at file:///.../node_modules/ts-node/esm.mjs:8:7
    at ModuleJob.run (node:internal/modules/esm/module_job:235:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:461:24)
    at async Hooks.register (node:internal/modules/esm/hooks:150:26)
    at async MessagePort.handleMessage (node:internal/modules/esm/worker:199:18)

The line of code in question;

const statsIfNotFound = new Stats();

Minimal reproduction

node --trace-deprecation --import ./ts-node.register.mjs path/to/any/file.ts

With ts-node.register.mjs containing the lines of code suggested here.

Specifications

  • ts-node version: 10.9.1
  • node version: v22.0.0
  • TypeScript version: 5.4.5
  • Operating system and version: Ubuntu 22.04 LTS, 5.15.0-105-generic x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions