无法导入Node.js中的Typescript文件

永远好奇

我正在尝试在Typescript文件中导入下划线模块,但是这会造成麻烦,因为当我在节点中运行Typescript模块时,它会引发错误:

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)
瑞安·卡瓦诺(Ryan Cavanaugh)

您必须编译TypeScript文件。然后,在节点中运行生成的.js文件。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章