除非提供了“--module"标志,否则无法编译模块 [英] Cannot compile modules unless the '--module' flag is provided
本文介绍了除非提供了“--module"标志,否则无法编译模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 typescript 1.5.3 和 Visual Studio 2015.
I have typescript 1.5.3 and visual studio 2015.
我在打字稿中使用外部模块,但由于以下错误而无法构建:构建:除非提供了‘--module’标志,否则无法编译模块."
I'm using external modules in my typescript, but it will not build due to the following error: "Build: Cannot compile modules unless the '--module' flag is provided."
打字稿设置:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Any CPU'">
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
<TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
<TypeScriptRemoveComments>False</TypeScriptRemoveComments>
<TypeScriptOutFile />
<TypeScriptOutDir />
<TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
<TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError>
<TypeScriptSourceMap>True</TypeScriptSourceMap>
<TypeScriptMapRoot />
<TypeScriptSourceRoot />
模块:
export class Functions {
errorHelper(xhr: any, errorType: any, exception?: any) {
var errorMessage = exception || xhr.statusText;
alert(`Account lookup failed. ${errorMessage}`);
}
getParameterByName(name: string) {
name = name.replace(/[[]/, '\[').replace(/[]]/, '\]');
var regex = new RegExp(`[?&]${name}=([^&#]*)`);
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/+/g, ' '));
}
推荐答案
看一看 在 Stackoverflow 上发布.VS2015 RTM 中存在一个错误.您必须编辑 csproj 文件才能解决该问题.
Take a look at post on Stackoverflow. There's a bug in VS2015 RTM. You have to edit csproj file in order to fix that issue.
修复:
- 右键单击项目,将其卸载,然后再次右键单击并进行编辑.
- 搜索
,然后定位到父元素,应该叫
. - 在
Condition
属性值中查找文本Any CPU
",将其改为AnyCPU
"——即去掉空格. - 如果您有其他构建条件的 TypeScript 设置,请再次搜索并重复更改.
- Right-click the project, unload it, then right click again and edit it.
- Search for
<TypeScriptModuleKind>
, and then locate the parent element, which should be called<PropertyGroup>
. - Look for the text "
Any CPU
" in theCondition
attribute value, change it to "AnyCPU
" -- i.e. remove the space. - Search again and repeat the change in case you have TypeScript settings for other build conditions.
这篇关于除非提供了“--module"标志,否则无法编译模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文