TypeError: argument should be a Buffer

1380 ワード

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. (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');

> o=Buffer(128);

> o.fill(0);

> o;

> 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. (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;

>