gpt4 book ai didi

javascript - 将参数传递给 TypeScript 编译器 Node 模块

转载 作者:行者123 更新时间:2023-11-30 12:19:49 25 4
gpt4 key购买 nike

我正在使用 TypeScript Node NPM module在我的项目中编译我的 .ts 文件。

简单案例

至于文档(我上面报告的链接指向的 NPM 页面中的文档),当编译一个简单的文件时,我只需要:

node node_modules/typescript/bin/tsc.js main.ts

不那么简单的情况

但是,我需要将参数传递给编译器,所以我这样做:

node node_modules/typescript/bin/tsc.js main.ts --module commonjs --out out/main.js

但是看起来 --module commonjs --out out/main.js 部分没有被考虑并且丢失了。

如何成功地将参数传递给通过'node'调用的tsc.js?谢谢

最佳答案

it looks like the --module commonjs --out out/main.js part is not considered and gets lost.

不是真的。它工作正常。很可能是您正在经历的事情:

不要同时使用--module--out

基本上不用--out。对于您的用例(将输出重定向到不同的目录)使用 --outDir

就个人而言,我不喜欢初学者的out:https://github.com/TypeStrong/atom-typescript/blob/master/docs/out.md

关于javascript - 将参数传递给 TypeScript 编译器 Node 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31462530/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com