Fix: Replace deprecated util.isArray with Array.isArray#74
Fix: Replace deprecated util.isArray with Array.isArray#74dpkprajapati wants to merge 1 commit intojaredhanson:masterfrom
Conversation
|
"This addresses the common util.isArray Node.js warning." |
|
🚨 [IMPORTANT NOTICE – Replacement Maintained] Hey 👋 Just a heads-up for anyone still waiting for updates on 📦 We’ve created a fully compatible, modern, actively maintained fork: ✅ Supports:
🛠 Maintained by CodeCorn™
Feel free to migrate or open issues/PRs directly there. |
|
Ran into this error with |
gotcha 👌—here’s a ready-to-paste set of solutions with all the options, plus a tiny PR patch we can offer upstream. ✅ Quick answer (drop-in, no code changes)You can keep npm (one-liner): npm i connect-flash@npm:@codecorn/connect-flash-new@latestnpm (package.json override): {
"overrides": {
"connect-flash": "npm:@codecorn/connect-flash-new@^1"
}
}then: npm install
Yarn Classic / Berry (resolutions): {
"resolutions": {
"connect-flash": "npm:@codecorn/connect-flash-new@^1"
}
}then: yarn installpnpm (overrides): {
"pnpm": {
"overrides": {
"connect-flash": "npm:@codecorn/connect-flash-new@^1"
}
}
}then: pnpm install
✳️ Optional: direct import (if you control the codebase)If you can touch the app code, you may import the fork explicitly: // Before
const flash = require('connect-flash');
// After
const flash = require('@codecorn/connect-flash-new');But the alias methods above are safer for dependencies like 🧰 Troubleshooting tips
🔁 Upstream fix (PR suggestion for
|
|
Hmm thanks @fgirolami29 but I think I'd wait for when |
|
I am just moving off of the dependency with just 20 extra lines of code in my application. Something like the following may work for you guys as well: |
This pull request addresses a DeprecationWarning issued by modern Node.js versions regarding the use of util.isArray.
Problem:
When running applications that depend on connect-flash with recent Node.js versions, the following deprecation warning is consistently logged:
(node:XXXXX) [DEP0044] DeprecationWarning: The util.isArrayAPI is deprecated. Please useArray.isArray() instead.
This warning specifically originates from line 67 in lib/flash.js, where util.isArray is used to check if msg is an array.
Solution:
This change replaces the deprecated util.isArray call with the modern, standard Array.isArray().
Removed var isArray = require('util').isArray; as it is no longer needed.
Replaced isArray(msg) with Array.isArray(msg) in the _flash function.
Benefits:
Eliminates the DEP0044 deprecation warning in Node.js, leading to cleaner console output.
Improves compatibility with current and future Node.js versions, as util.isArray may eventually be removed.
Aligns the codebase with modern JavaScript best practices, as Array.isArray() is the preferred method for array detection.
This change is purely a maintenance update and does not alter the functionality or behavior of connect-flash. It simply updates an outdated API usage to a current standard.