gpt4 book ai didi

typescript - 无法写入文件 '..../public/scripts/script.js',因为它会覆盖输入文件

转载 作者:搜寻专家 更新时间:2023-10-30 21:23:32 24 4
gpt4 key购买 nike

我在 Visual Studio 2017 中使用 TypeScript Basic Node.js Express 4 Application 模板创建了一个项目。

我有一个文件 /public/scripts/script.js 用于下载到客户端。当我尝试构建应用程序时,我得到:

TS5055 Cannot write file 'd:/documents/visual studio 2017/Projects/ExpressApp/ExpressApp/public/scripts/script.js' because it would overwrite input file.

这个错误是什么意思?为什么要写入这个文件?即使我从项目中排除这个文件,错误仍然存​​在。我该如何纠正这个问题?

我将文件夹从scripts重命名为js,问题还是一样。成功构建的唯一方法是删除文件。那么我应该把为客户准备的文件放在哪里?

是否有关于 TypeScript/Node 项目的 Visual Studio 项目文件夹结构的文档?

最佳答案

从@unional 的提示中我找到了我的答案,即在 tsconfig.json 中有一个明确的 exclude 选项。

根据 typescriptlang.org :

the compiler defaults to including all TypeScript (.ts, .d.ts and .tsx) files in the containing directory and subdirectories except those excluded using the "exclude" property. JS files (.js and .jsx) are also included if allowJs is set to true

如果未指定 exclude,则仅排除 node_modules 和其他几个。以下对我有用:

"exclude":  [ "node_modules", "public"]

请注意,exclude 不是 compilerOptions 的属性,但与 tsconfig.json 中的 compilerOptions 处于同一级别。

关于typescript - 无法写入文件 '..../public/scripts/script.js',因为它会覆盖输入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45106844/

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