[英]Node.js fs.createWriteStream undefined function
I am trying to write data to a text file in Node.js. When initializing the write stream I get the following error message:我正在尝试将数据写入 Node.js 中的文本文件。在初始化写入 stream 时,我收到以下错误消息:
Be sure you have included at the top of your node program 确保已将其包含在节点程序的顶部
var fs = require('fs');
Also It looks like you spelled 'Stream' incorrectly 还好像你拼错了“流”
fs.createWriteSteam > fs.createWriteStream
Another issue that may come up is trying to get createWriteStream from 'fs/promises'.可能出现的另一个问题是尝试从“fs/promises”获取 createWriteStream。 It doesn't exist on 'fs/promises'.它不存在于“fs/promises”上。 (At least on NodeJS version 14); (至少在 NodeJS 版本 14 上);
My solution was to import both:我的解决方案是同时导入:
var fs = require('fs');
var fsPromises = require('fs/promises');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.