jaredhanson / connect-flash

Flash message middleware for Connect and Express.
MIT License
1.24k stars 158 forks source link

Update flash.js to fix:DeprecationWarning: The `util.isArray` API is deprecated. Please use `Array.isArray()` instead. #57

Open penn201500 opened 5 months ago

penn201500 commented 5 months ago

Fix: DeprecationWarning: The util.isArray API is deprecated. Please use Array.isArray() instead.

Since modifying files in node_modules will be overwritten when you run npm install, use patch-package to persist these changes.

  1. npm install patch-package postinstall-postinstall
  2. Modify flash.js
  3. npx patch-package connect-flash
  4. Add the following script to your package.json to ensure the patch is applied after each npm install: "scripts": { "postinstall": "patch-package" }
Chorwhat commented 1 month ago

Hi @penn201500 I came across this PR after encountering the same error. I also noticed my changes get overwritten whenever i run npm install. My question is if the source code for this package was changed to use Array.isArray() instead, would the patch still be needed? Why is the proposed solution to add a patch to change the source instead of changing the source directly?

Sorry if this is a noob question, I am learning

penn201500 commented 1 month ago

Hi @penn201500 I came across this PR after encountering the same error. I also noticed my changes get overwritten whenever i run npm install. My question is if the source code for this package was changed to use Array.isArray() instead, would the patch still be needed? Why is the proposed solution to add a patch to change the source instead of changing the source directly?

Sorry if this is a noob question, I am learning

Hi, @Chorwhat. Suppose the source code for this package fixed the warning. The patch is not needed anymore.