2014-04-16 10 views
1

내가 타이프 스크립트 파일에 밑줄 모듈을 수입하려고하지만 노드의 타이프 라이터 모듈을 실행하면 오류가 발생하기 때문에 그 문제를 만드는 오전 :수 없습니다

Code:  
import _ = require('underscore'); 

Error: 
import _ = require('underscore'); 
^^^^^^ 
SyntaxError: Unexpected reserved word 
    at Module._compile (module.js:439:25) 
    at Object.Module._extensions..js (module.js:474:10) 
    at Module.load (module.js:356:32) 
    at Function.Module._load (module.js:312:12) 
    at Module.require (module.js:364:17) 
    at require (module.js:380:17) 

답변

4

을 TypeScript 파일을 컴파일해야합니다. 그런 다음 생성 된 .js 파일을 노드에서 실행하십시오.

+0

Webstorm (내가 사용중인 IDE)에 자동으로 파일 감시자가 있습니다. 다른 가능성이 있습니까? – EternallyCurious

+0

WebStorm에서 파일을 올바르게 컴파일하지 못했거나 .js 대신 .ts 노드를 실행 중입니다. –

+0

알았습니다! 감사. – EternallyCurious