赞
踩
- function writeFile(){
- fs.writeFile("how.html","bye");
- return "write successful";
-
- }
报错如下:
- throw new ERR_INVALID_CALLBACK(callback);
- ^
-
- TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined
- [90m at maybeCallback (node:fs:174:3)[39m
- [90m at Object.writeFile (node:fs:2091:14)[39m
- at Object.writeFile [as /writeFile] (C:\陆哥\project_nodejs\src\file\requestHandlers.js:10:5)
- at route (C:\陆哥\project_nodejs\src\router\router.js:3:26)
- at Server.onRequest (C:\陆哥\project_nodejs\src\router\server.js:7:12)
- [90m at Server.emit (node:events:394:28)[39m
- [90m at parserOnIncoming (node:_http_server:927:12)[39m
- [90m at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)[39m {
- code: [32m'ERR_INVALID_CALLBACK'[39m
查了一下发现原来是writeFile调用还需要第三个参数callback
修改如下
fu
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。