node-tesseract icon indicating copy to clipboard operation
node-tesseract copied to clipboard

Solve "[DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated."

Open GoooodSky opened this issue 6 years ago • 8 comments

Here is a contemporary solution from @BenjaminChoou:

1. Find where your node-tesseract module is.

On my computer, the path is :

C:\Users\BenjaminChou\node_modules\node-tesseract\lib

2. Open and modify tesseract.js as follow:

Before: fs.unlink(files[0]); Now: fs.unlink(files[0], err => { if (err) console.log(err) });

GoooodSky avatar Apr 24 '18 08:04 GoooodSky

Thanks!

JesseWo avatar May 06 '18 17:05 JesseWo

@uchihaty Why don't you create a PR for this?

ceremcem avatar May 13 '18 18:05 ceremcem

Is this project sill active? Just an FYI, I'm testing with Node v10 and this error now breaks the project.

Error message:

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function at makeCallback (fs.js:148:11) at Object.fs.unlink (fs.js:1016:14) at /.../node_modules/node-tesseract/lib/tesseract.js:99:14 at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:422:3) [ERROR] 13:14:21 TypeError [ERR_INVALID_CALLBACK]

jonathonadams avatar Jun 24 '18 10:06 jonathonadams

Same issue Encountered, node version v11.0.0

Lucien-X avatar Oct 26 '18 07:10 Lucien-X

Same issue Encountered, node version v10.9.0

liuwei0514 avatar Dec 17 '18 16:12 liuwei0514

Same issue. Probably, the fix should include calling the caller's callback after the unlink...

fs.unlink(files[0], err => { err ? callback(err, null) : callback(null, data); });

halaprop avatar Jul 30 '19 18:07 halaprop

@halaprop I think something is wrong with your suggestion: Where is the callback and data defined?

ceremcem avatar Jul 30 '19 19:07 ceremcem

@ceremcem - Sorry, I should have been more explicit. I was looking here, line 100 is where unlink is called. callback is passed to the containing function (process()), and data is the result of an fs.read which encloses this code.

halaprop avatar Jul 31 '19 19:07 halaprop