TypeStrong / ts-node

TypeScript execution and REPL for node.js
https://typestrong.org/ts-node
MIT License
12.92k stars 532 forks source link

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

Open darcyrush opened 6 months ago

darcyrush commented 6 months ago

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

Byron2016 commented 2 months ago

maybe some update on this warning?

RomainLanz commented 2 months ago

We made ts-node-maintained in the meanwhile

aimeerivers commented 1 week ago

thank you @RomainLanz for ts-node-maintained 🥰

are there any plans to update ts-node again at some point?