简体   繁体   中英

Error: Cannot find module 'tslint/lib/lint' when trying to extend tslint-microsoft-contrib

This is our environment

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

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

This is our tslint.json configuration.

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

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)     

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

You need to downgrade to tslint 3.xx, 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM