Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to read tslint, not found. #133

Open
kevin074 opened this issue Aug 20, 2018 · 4 comments
Open

unable to read tslint, not found. #133

kevin074 opened this issue Aug 20, 2018 · 4 comments

Comments

@kevin074
Copy link

I init a tslint via https://palantir.github.io/tslint/ quick start direction
Then installed typescript-formatter according to direction on github
Finally tried tsfmt -r to test the package, error showed:
"Error: Cannot find module 'tslint'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at /usr/local/lib/node_modules/typescript-formatter/lib/provider/tslintjson.js:131:86"

then tried tsfmt -r --no-tslint and the compilation was completed with replacements done.

All commands done at the root directory where tsconfig.json and tslint.json also lives.
I have also tried to do the commands in the folder where the TS files lives (but not the .json files), and the same error is shown.

@stweedie
Copy link
Contributor

if you installed typescript-formatter globally, it also requires tslint globally.

That's a workaround though. In my opinion, if this is the case, tslint should be listed as a dependency of typescript-formatter

@kevin074
Copy link
Author

i do have tslint globally though. The quick start directions have listed so and also just checked outside of my project folder with "tslint" command :( anything else you can think of ?

@stweedie
Copy link
Contributor

sorry for the delay. I'm terrible about checking GH notifications since my current project uses a different site for source control.

Can you try to install both tslint and typescript formatter locally and running it from the node_modules/.bin folder?

also, make sure tsfmt, tsc, and tslint are accessible from path:

tsfmt -v
tslint -v

though I would think they are since they're installed globally. These are just diagnostic steps though. It seems more like a problematic npm / node configuration than anything, since the code just delegates to node's 'require' method to load tslint.

I'm definitely curious though. Can you list all global packages you have installed, as well as the dependencies from your project? (obviously you can omit anything private / personal) I'll try and recreate your installation and see if I can repro

@kevin074
Copy link
Author

OMG thanks!!

I did the local installation and it worked fine, which was strange to me. So then I found that you could npm install -g tslint instead of yarn global add tslint.

for some reason installing through npm allowed tsfmt to find tslint now. How weird if you know anything about why please let me know.

I think the documentation on this github should update about this. Cause on the tslint website it said to use yarn. Although I understand that most people probably would have just npm install -g tslint without thinking ... lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants