TypeError: argument should be a Buffer

TypeError: argument should be a Buffer,第1张

概述1、错误描述&gt y.copy(0,10);TypeError: argument should be a Buffer at TypeError (native) at repl:1:3 at REPLServer.defaultEval (repl.js:262:27) a

1、毛病描写

> y.copy(0,10);TypeError: argument should be a Buffer at TypeError (native) at repl:1:3 at REPLServer.defaultEval (repl.Js:262:27) at bound (domain.Js:287:14) at REPLServer.runBound [as eval] (domain.Js:300:12) at REPLServer.<anonymous> (repl.Js:431:12) at emitOne (events.Js:82:20) at REPLServer.emit (events.Js:169:7) at REPLServer.Interface._online (readline.Js:211:10) at REPLServer.Interface._line (readline.Js:550:8)>
2、毛病缘由

     buffer.copy(Buffer对象,开始写入处);

     但是这里Buffer对象写成了0


3、解决办法

> y=Buffer('wo ai ni');<Buffer 77 6f 20 61 69 20 6e 69>> o=Buffer(128);<Buffer 00 00 00 00 01 00 00 00 80 61 37 02 00 00 00 00 02 00 00 00 00 00 00 0088 94 43 00 00 00 00 00 01 00 00 00 00 00 00 00 e8 aa 43 00 00 00 00 00 02 00 ... >> o.fill(0);<Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... >> o;<Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... >> y.copy(0,10);TypeError: argument should be a Buffer at TypeError (native) at repl:1:3 at REPLServer.defaultEval (repl.Js:262:27) at bound (domain.Js:287:14) at REPLServer.runBound [as eval] (domain.Js:300:12) at REPLServer.<anonymous> (repl.Js:431:12) at emitOne (events.Js:82:20) at REPLServer.emit (events.Js:169:7) at REPLServer.Interface._online (readline.Js:211:10) at REPLServer.Interface._line (readline.Js:550:8)> y.copy(o,10);8> o;<Buffer 00 00 00 00 00 00 00 00 00 00 77 6f 20 61 69 20 6e 69 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... >>

总结

以上是内存溢出为你收集整理的TypeError: argument should be a Buffer全部内容,希望文章能够帮你解决TypeError: argument should be a Buffer所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1016149.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-22
下一篇2022-05-22

发表评论

登录后才能评论

评论列表(0条)

    保存