小编MAK*_*MAK的帖子

TypeError [ERR_INVALID_OPT_VALUE_ENCODING] 值“./ab.txt”对于选项“encoding”无效

const fs=require('fs');

var read = fs.createReadStream(__dirname,'./ab.txt','utf8');
read.on('data',function(chunk){
  console.log("New Chunk Received ");
  console.log(chunk);
});
Run Code Online (Sandbox Code Playgroud)

我在 express 应用程序中使用 fs 模块并尝试读取文本文件,但命令提示符给了我以下错误。

internal/fs/utils.js:41 throw new ERR_INVALID_OPT_VALUE_ENCODING(encoding); ^

TypeError [ERR_INVALID_OPT_VALUE_ENCODING]:值“./ab.txt”对于选项“encoding”无效

node.js express

5
推荐指数
1
解决办法
6464
查看次数

标签 统计

express ×1

node.js ×1