F
F
fraps012019-09-22 17:00:59
Node.js
fraps01, 2019-09-22 17:00:59

How to solve TypeError [ERR_INVALID_CALLBACK]: Callback must be a function?

After executing these commands (Before these commands everything worked fine)

$ sudo npm cache clean -f
$ sudo npm install -g n
$ sudo n stable

Error started popping up
TypeError [ERR_INVALID_CALLBACK]: Callback must be a function

Full error log
TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
1|bot      |     at maybeCallback (fs.js:128:9)
1|bot      |     at Object.appendFile (fs.js:1217:14)
1|bot      |     at Object.fallback (/usr/lib/node_modules/pm2/node_modules/pmx/node_modules/vxx/node_modules/continuation-local-storage/node_modules/async-listener/index.js:518:15)
1|bot      |     at Object.appendFile (/usr/lib/node_modules/pm2/node_modules/pmx/node_modules/vxx/node_modules/continuation-local-storage/node_modules/async-listener/index.js:542:53)
1|bot      |     at myconsolelog (/bot/bot.js:921:19)
1|bot      |     at Handshake._callback (/bot/bot.js:107:5)
1|bot      |     at Handshake.Sequence.end (/bot/node_modules/mysql/lib/protocol/sequences/Sequence.js:85:24)
1|bot      |     at Handshake.Sequence.OkPacket (/bot/node_modules/mysql/lib/protocol/sequences/Sequence.js:94:8)
1|bot      |     at Protocol._parsePacket (/bot/node_modules/mysql/lib/protocol/Protocol.js:280:23)
1|bot      |     at Parser.write (/bot/node_modules/mysql/lib/protocol/Parser.js:74:12)

Line code 921

function myconsolelog(text){
    console.log(text);
    require('fs').appendFile('bot_debug.log', text + "\r\n");
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hzzzzl, 2019-09-22
@fraps01

fs.appendFile('bot_debug.log', text + "\r\n", (err) => {
  if (err) {
    console.log('че то пошло не так');
  }
});

https://nodejs.org/api/fs.html#fs_fs_appendfile_pa...
it definitely needs a third argument with a function

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question