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

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)
    }
})

看出问题了么

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

效果图 

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

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

上一篇:【TcaplusDB知识库】TDR表GOSDK示例代码-更新数据


下一篇:Vue-请求工具axios