本文共 926 字,大约阅读时间需要 3 分钟。
node util.log
If you experience the error “util.pump is not a function” while running a Node.js app or a Node.js snippet, it’s because the app code is too old for the current Node.js runtime.
如果在运行Node.js应用程序或Node.js代码段时遇到错误“ util.pump不是函数”,这是因为该应用程序代码对于当前的Node.js运行时而言太旧了。
The pump()
method that Node.js provided wrote a readable to a writable stream using this syntax:
Node.js提供的pump()
方法使用以下语法将可读写入可写流:
util.pump(readableStream, writableStream)
This method is now gone, deprecated for a long time and removed when Node.js 6.0 was released in April 2016.
该方法现已消失,不推荐使用很长时间,并于2016年4月发布Node.js 6.0时将其删除。
Luckily, it’s easy to fix this problem.
幸运的是,解决此问题很容易。
Replace the above syntax with:
将以上语法替换为:
const { pipeline } = require('stream')//...pipeline(readableStream, writableStream, () => {})
The third argument is a callback function that will be called when the pipeline is done.
第三个参数是在完成管道后将调用的回调函数。
.
。
翻译自:
node util.log
转载地址:http://ptmgb.baihongyu.com/