Registry
Nnodejs avatar

nodejs/http-classes-with-new

Handle DEDEP0195: Instantiating node:http classes without new

nodejs48 executions

  • transformation
  • migration
  • nodejs
Connect a repo
npx codemod @nodejs/http-classes-with-new

http.request DEP0195

This recipe provides a guide for migrating from the deprecated http.request and its synchronous and promise-based counterparts to the new http.request method in Node.js.

See DEP0195.

Examples

diff
  // import { IncomingMessage, ClientRequest } from "node:http";
  // const http = require("node:http");

- const message = http.OutgoingMessage();
+ const message = new http.OutgoingMessage();
- const response = http.ServerResponse(socket);
+ const response = new http.ServerResponse(socket);

- const incoming = IncomingMessage(socket);
+ const incoming = new IncomingMessage(socket);
- const request = ClientRequest(options);
+ const request = new ClientRequest(options);

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.