除非提供'--module'标志,否则无法编译模块 [英] Cannot compile modules unless the '--module' flag is provided

查看:457
本文介绍了除非提供'--module'标志,否则无法编译模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有打字稿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, ' '));
}

推荐答案

看看

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.

要解决:

  1. 右键单击该项目,将其卸载,然后再次右键单击并进行编辑.
  2. 搜索<TypeScriptModuleKind>,然后找到父元素,应将其命名为<PropertyGroup>.
  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.

这篇关于除非提供'--module'标志,否则无法编译模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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