2012-11-22 2 views
0

Node.js를 시작하기 전에 몇 가지 아이디어를 테스트하기 위해 Underscore를 시험해보고 싶습니다.Node REPL + Underscore는 아무런 메서드도 반환하지 않습니다.

나는 게시물 here, here 및 마지막으로 here을 읽었습니다.

_을 REPL에서 사용할 수없는 이유가 있습니다. 그러나 둘 모두 밑줄 개체를 재 할당하지 않습니다. 예를 들어

,

> var _u = require('underscore'); 
    { _: 
    { [Function] 
     VERSION: '1.0.2', 
     forEach: [Function], 
     map: [Function], 
     reduce: [Function], 
     reduceRight: [Function], 
     detect: [Function], 
     ...feeling good about myself... 

> _u.uniq([1,2,3,4,4,44]); 

반환 값 :이 외에 작업 글로벌 밑줄 개체의 이름을 바꿀 수없는 이유에

TypeError: Object #<Object> has no method 'uniq' 
at repl:1:4 
at REPLServer.self.eval (repl.js:109:21) 
at rli.on.self.bufferedCmd (repl.js:258:20) 
at REPLServer.self.eval (repl.js:116:5) 
at Interface.<anonymous> (repl.js:248:12) 
at Interface.EventEmitter.emit (events.js:96:17) 
at Interface._onLine (readline.js:200:10) 
at Interface._line (readline.js:518:8) 
at Interface._ttyWrite (readline.js:736:14) 
at ReadStream.onkeypress (readline.js:97:10) 

어떤 아이디어? _u에 할당 된 버전은 1.0.2입니다.

답변

2

1.0.2 꽤 오래되었습니다. 1.4.2이 현재 버전입니다. 나는이 방법이 라이브러리 버전에 존재하지 않는다고 확신한다.

업그레이드 시간.

+0

업데이트하려면 : 'npm update underscore' – JohnnyHK

+0

내 무지를 기쁘게 해줘서 고마워. 업데이트는 매력처럼 작동했습니다. – rhodee

관련 문제