Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 阻止发送ts文件_Node.js_Angular_Typescript - Fatal编程技术网

Node.js 阻止发送ts文件

Node.js 阻止发送ts文件,node.js,angular,typescript,Node.js,Angular,Typescript,我在Angular CLI中使用node JS,我看到我的.ts文件通过HTTP发送到客户端。例如http://localhost/main.ts将向用户发送我的main.ts文件 据我所知,ts在发送到浏览器之前被传输到js文件中,对吗?如果是这样,我如何防止.ts被发送,并使服务器只发送.js文件 多谢各位 TL;DR:尝试使用ng serve-prod--aot运行项目 对于Angular cli项目。。当您完成开发并最终准备好让现实世界的用户使用您的应用程序时,您应该在项目的根目录中运

我在Angular CLI中使用node JS,我看到我的.ts文件通过HTTP发送到客户端。例如
http://localhost/main.ts
将向用户发送我的main.ts文件

据我所知,ts在发送到浏览器之前被传输到js文件中,对吗?如果是这样,我如何防止.ts被发送,并使服务器只发送.js文件

多谢各位

TL;DR:尝试使用
ng serve-prod--aot运行项目


对于Angular cli项目。。当您完成开发并最终准备好让现实世界的用户使用您的应用程序时,您应该在项目的根目录中运行
ng build-prod--aot
。。这将在项目根目录中创建
dist
目录,其中包含实际的最终javascript文件和html资产,这些文件和资产将通过常规HTTP(使用生产Web服务器,例如,或apache)提供给用户。请注意,在最终的
dist
目录中没有
.ts
文件

添加-prod标志确保它将针对生产进行优化。
--aot标志是用于的。

谢谢。。我会试试的