Pregunta

I am trying to import the underscore module in a Typescript file, but its creating trouble because when I run the typescript module in node, it throws an error:

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)
¿Fue útil?

Solución

You have to compile the TypeScript file. Then, run the generated .js file in node.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top