Node.js® is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.
Published By From Node.js News · 1 min read
CodeNode.js v16 to v18
This article covers a part of the migration from Node.js v16 to v18. The userland migrations team is working on more codemods to help you with the migration.
This page provides a list of codemods to help you migrate your code from Node.js v16 to v18.
In Node.js v18, the DEP0159 deprecation was introduced, which deprecated the ERR_INVALID_CALLBACK error code in favor…
This is an excerpt. The full article is published by Node.js News.
Answers to common questions regarding this article's topic, architecture, and practical applications.
This page provides a list of codemods to help you migrate your code from Node.js v16 to v18.
Definition / Understanding
In Node.js v18, the DEP0159 deprecation was introduced, which deprecated the ERR_INVALID_CALLBACK error code in favor of ERR_INVALID_ARG_TYPE. This codemod will help you replace any references to the old error code with the new one. The source code for this codemod can be found in the err-invalid-callback directory. You can find this codemod in the Codemod Registry.
General
This article covers a part of the migration from Node.js v16 to v18. The userland migrations team is working on more codemods to help you with the migration.
Definition / Understanding
try {
fs.readFile("file.txt", "invalid-callback");
} catch (err) {
- if (err.code === "ERR_INVALID_CALLBACK") {
+ if (err.code === "ERR_INVALID_ARG_TYPE") {
console.error("Invalid callback provided");
}
}Diff
Also handles deduplication when both codes were already checked: