其他分享
首页 > 其他分享> > TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined

作者:互联网

描述:

VS Code版本:

版本: 1.63.2
提交: 899d46d82c4c95423fb7e10e68eba52050e30ba3
日期: 2021-12-15T09:40:02.816Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19043

node.js版本

C:\Users\dell>node -v
v14.15.0

出现问题

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined

代码如下(错误代码)

const fs = require('fs')
const p = new Promise(() => {
  fs.readFile('./他.txt'),
    (err, data) => {
      if (err) {
        console.log('文件读取失败')
        return
      }
      console.log(data)
    }
})

看出问题了么

效果图 

 刚贴出来就感觉哪里怪怪的

标签:function,Received,TypeError,node,ERR,fs,const,data,must
来源: https://blog.csdn.net/nanyangnongye/article/details/122782071