ts-node icon indicating copy to clipboard operation
ts-node copied to clipboard

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

Open darcyrush opened this issue 9 months ago • 2 comments

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

darcyrush avatar May 01 '24 12:05 darcyrush

maybe some update on this warning?

Byron2016 avatar Sep 06 '24 12:09 Byron2016

We made ts-node-maintained in the meanwhile

RomainLanz avatar Sep 06 '24 15:09 RomainLanz