简体   繁体   English

抛出新的 ERR_INVALID_CALLBACK(回调);

[英]throw new ERR_INVALID_CALLBACK(callback);

I am using Node.js v17.1.0我正在使用 Node.js v17.1.0

enter image description here在此处输入图片说明

And getting this error :并收到此错误:

enter image description here在此处输入图片说明

As per the documentation on fs callback api , and the error message you are getting, you need to pass a callback to the appendFile function as it expects one as the last parameter:根据有关 fs callback api文档以及您收到的错误消息,您需要将回调传递给 appendFile 函数,因为它希望将一个回调作为最后一个参数:

   fs.appendFile('greeting.txt', `Hello ${user.username} !`, (err) => {
       if (err) throw err;
       console.log('The data was appended to greeting.txt!');
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM