tslint.yaml configurationextends:
- 'tslint:latest'
- tslint-eslint-rules
- tslint-config-prettier
defaultSeverity: error
rulesDirectory: tslint-plugin-prettier
rules:
prettier: true
max-line-length:
options:
- 120
no-constant-condition: true
trailing-comma: false
object-literal-sort-keys: false
ordered-imports: false
no-console: false
no-unused-expression:
- true
- allow-fast-null-checks
package.json configuration...
"scripts": {
"lint": "tslint -c tslint.yaml '*.ts?(x)'; exit 0",
}
...
yarn lint
yarn run v1.5.1
$ tslint -c tslint.yaml '*.ts?(x)'; exit 0
module.js:545
throw err;
^
Error: Cannot find module 'typescript'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:470:25)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (xxx/node_modules/tslint/lib/linter.js:22:10)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
The xxx/node_modules/tslint/lib/linter.js:22:10 :
...
var ts = require("typescript");
...
Lint the ts files.
When I install the typescript locally, it works.
Does typescript can't be installed globally?
Hey, according to this SO post: https://stackoverflow.com/questions/15636367/nodejs-require-a-global-module-package, it looks like locally installed modules don't look for modules from the global module directory.
I think that you can install both tslint/typescript locally or globally, but not mixed.
Most helpful comment
Hey, according to this SO post: https://stackoverflow.com/questions/15636367/nodejs-require-a-global-module-package, it looks like locally installed modules don't look for modules from the global module directory.
I think that you can install both tslint/typescript locally or globally, but not mixed.