如何在 VS2015 项目中提供模块标志? [英] How to provide the module flag in a VS2015 project?

查看:31
本文介绍了如何在 VS2015 项目中提供模块标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 VS2015 在 web 项目中创建了一个新的 .ts 文件.在 TypeScript Build 下的项目属性中,我检查了 Module System = AMD.

I've created a new .ts file in a webproject using VS2015. In the properties for the project under TypeScript Build I've checked Module System = AMD.

然后在尝试编写外部模块时出现以下错误.

Then when trying to write a external module i get the following error.

除非提供了--module"标志,否则无法编译模块.

Cannot compile modules unless the '--module' flag is provided.

在哪里提供模块标志?

推荐答案

这似乎是一个 bugVS2015 RTM.项目 TypeScript 设置被错误地保存到 .csproj 文件中,因此 TypeScript 编译器不会读取它们.

It seems to be a bug with VS2015 RTM. The project TypeScript settings are saved incorrectly to the .csproj file, so the TypeScript compiler isn't reading them.

修复:

  1. 右键单击项目,将其卸载,然后再次右键单击并进行编辑.
  2. 搜索,然后定位到父元素,应该叫.
  3. Condition属性值中查找文本Any CPU",将其改为AnyCPU"——即去掉空格.
  4. 如果您有其他构建条件的 TypeScript 设置,请再次搜索并重复更改.
  1. Right-click the project, unload it, then right click again and edit it.
  2. Search for <TypeScriptModuleKind>, and then locate the parent element, which should be called <PropertyGroup>.
  3. Look for the text "Any CPU" in the Condition attribute value, change it to "AnyCPU" -- i.e. remove the space.
  4. Search again and repeat the change in case you have TypeScript settings for other build conditions.

请注意,在修复此错误之前,您需要编辑 .csproj 文件以修改 TypeScript 设置.如果您尝试从项目设置区域进行更改,它只会在项目文件中再次生成具有错误条件值的新设置.

Note that until this bug is fixed, you'll need to edit the .csproj file to modify TypeScript settings. If you try to make the change from the project settings area, it will just generate new settings in the project file with the wrong condition value again.

此外,您可能正在阅读有关使用 tsconfig.json 文件代替在 VS2015 中提供设置的信息.但是,目前似乎仅针对网站项目类型实现了此功能,而不针对 Web 应用程序项目.

Also, you may be reading about using a tsconfig.json file instead for providing the settings in VS2015. However, it seems that this capability is currently only implemented for the Website project type and not for Web Application projects.

这篇关于如何在 VS2015 项目中提供模块标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆