简体   繁体   English

TypeScript是否需要node.js才能运行?

[英]Does TypeScript require node.js to run?

Installing TypeScript requires node.js. 安装TypeScript需要node.js。 And I assume that TypeScript uses Node.js to compile the .ts to a .js file. 我假设TypeScript使用Node.js将.ts编译为.js文件。

My question is, does that created .js file require node.js? 我的问题是,创建的.js文件是否需要node.js? The ones I've seen so far appear not to. 到目前为止,我所看到的似乎没有。 I don't want to load node.js into my html pages if it's not used. 如果不想使用,我不想将node.js加载到我的html页面中。

thanks - dave 谢谢-戴夫

No, TypeScript just emits regular JavaScript. 不,TypeScript仅发出常规JavaScript。

If you use the "external modules" feature of the language ( import x = require('foo'); ) you'll need to compile for either CommonJS (node) or AMD (require.js) and have those available, but that's opt-in. 如果您使用该语言的“外部模块”功能( import x = require('foo'); ),则需要针对CommonJS(节点)或AMD(require.js)进行编译,并提供可用的功能,但这就是选择参加。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM