错误:尝试扩展 tslint-microsoft-contrib 时找不到模块“tslint/lib/lint" [英] Error: Cannot find module 'tslint/lib/lint' when trying to extend tslint-microsoft-contrib

查看:37
本文介绍了错误:尝试扩展 tslint-microsoft-contrib 时找不到模块“tslint/lib/lint"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我们的环境

> \node_modules\.bin\tslint --version
4.0.1

> npm install --save-dev tslint-microsoft-contrib
`-- tslint-microsoft-contrib@2.0.13

这是我们的 tslint.json 配置.

This is our tslint.json configuration.

{
    "extends": [
        "./node_modules/tslint-microsoft-contrib/tslint.json"
    ]
}

当我们使用该配置运行本地 tslint 时会发生这种情况.

This is what happens when we run our local tslint with that configuration.

> node_modules\.bin\tslint --config .\tslint.json --project .\tsconfig.json
module.js:471
throw err;
^

Error: Cannot find module 'tslint/lib/lint'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\myApp\node_modules\tslint-microsoft-contrib\insecureRandomRule.js:7:12)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)     

我们如何在扩展 tslint-microsoft-contrib 的配置上运行 tslint?

How can we run tslint on a configuration that extends tslint-microsoft-contrib?

推荐答案

您需要降级到 tslint 3.xx,tslint-microsoft-contrib 尚不支持 tslint 4,PR #314 应该解决这个问题,PR 看起来已经完成,但测试需要升级 grunt-tslint 以支持 tslint4 也是.同时,您可以继续使用 tslint@3

You need to downgrade to tslint 3.x.x, tslint-microsoft-contrib doesn't yet support tslint 4, PR #314 should fix that, the PR looks done, but the tests require grunt-tslint to be upgraded to support tslint 4 as well. For the mean time, you can continue to use tslint@3

这篇关于错误:尝试扩展 tslint-microsoft-contrib 时找不到模块“tslint/lib/lint"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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