node-tesseract
node-tesseract copied to clipboard
Solve "[DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated."
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) });
Thanks!
@uchihaty Why don't you create a PR for this?
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]
Same issue Encountered, node version v11.0.0
Same issue Encountered, node version v10.9.0
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 I think something is wrong with your suggestion: Where is the callback
and data
defined?
@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.