简体   繁体   English

Node.js fs.createWriteStream 未定义 function

[英]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.

相关问题 类型错误:fs.createWriteStream 不是 Node 中的 function - TypeError: fs.createWriteStream is not a function in Node Node.js:如何使用fs.createWriteStream创建具有755权限的文件 - Node.js: How to create file with 755 permissions with fs.createWriteStream Node.js:检测到一个文件,该文件通过fs.createWriteStream()打开,已被删除 - Node.js: Detecting a file, opened with fs.createWriteStream(), becoming deleted 未捕获的TypeError:fs.​​createWriteStream不是函数 - Uncaught TypeError: fs.createWriteStream is not a function 带有fs.createWriteStream()的节点请求模块创建一个空文件 - Node request module with fs.createWriteStream() creates an empty file ExcelJS writeFile 不起作用:Uncaught TypeError: fs.createWriteStream is not a function - ExcelJS writeFile not working: Uncaught TypeError: fs.createWriteStream is not a function 错误TypeError:fs.​​createWriteStream不是函数Angular 6 GIF导出 - ERROR TypeError: fs.createWriteStream is not a function Angular 6 GIF export 如何确保fs.createWriteStream在函数继续执行之前完成; 仅保存一部分图像 - How to make sure fs.createWriteStream finishes before function continues; only fraction of image being saved 使用fs.createWriteStream在Node.js中写入大文件 - Writing large file in Nodejs using fs.createWriteStream 是否可以使用 fs.createWriteStream 在文件中间写入文本? (或一般在nodejs中) - Is it possible to write text in the middle of a file with fs.createWriteStream ? (or in nodejs in general)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM