【问题标题】:Build Module failed when using TSLint with webpack将 TSLint 与 webpack 一起使用时构建模块失败
【发布时间】:2017-01-16 09:01:03
【问题描述】:

我正在尝试在我的项目上运行 TSLint,但在尝试使用 webpack 构建时它当前失败。我创建了一个具有以下结构的项目的简单复制:

\tslint-issue  
    |-\src
    |   |-Base.ts
    |   |-Derived.ts
    |   |-index.tsx
    |-babel.rc
    |-index.html
    |-package.json
    |-tsconfig.json
    |-webpack.config.json

Base 和 Derived 是非常简单的类定义。但是当我运行时

webpack

我收到以下消息:

    ERROR in ./src/Derived.ts
Module build failed: TypeError: this.computeFullOptions is not a function
    at Object.Linter (c:\Code\tslint-issue\node_modules\tslint\lib\tslint.js:15:29)
 @ ./src/index.tsx 2:16-36

当我从 webpack.config.json

中删除以下部分时
            {
                test: /\.ts$/,
                loader: 'tslint'
            },

它工作正常。如果需要更多信息,我可以提供任何必要的项目。 index.tsx 导入Derived.ts 文件中的Derived 类,内容如下:

import { Derived } from "./Derived";

var d = new Derived(25);
console.log(d.AbsMethod());

提前致谢!

【问题讨论】:

    标签: webpack tslint


    【解决方案1】:

    您缺少 tslint-loader

    npm install --save-dev tslint-loader 应该可以解决问题。

    【讨论】:

    • 完全修复它!非常感谢。从错误中看不出发生了什么。我尝试编辑您的评论以删除 npm 之后的破折号 (-),但这还不足以进行编辑。好眼力,不是我看到我什至没有包含 package.json。
    • 感谢指出错字!我已经修复了它,并同意这个错误有点误导。在谷歌搜索相同的红鲱鱼错误消息后,我发现了你的问题并最终弄清楚了。
    猜你喜欢
    • 2019-11-06
    • 2021-08-15
    • 1970-01-01
    • 2016-02-10
    • 1970-01-01
    • 2021-05-07
    • 1970-01-01
    • 2018-02-11
    • 1970-01-01
    相关资源
    最近更新 更多