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

problem of eslint_d with vim #17

Closed
ruanyl opened this issue Nov 18, 2015 · 9 comments
Closed

problem of eslint_d with vim #17

ruanyl opened this issue Nov 18, 2015 · 9 comments

Comments

@ruanyl
Copy link
Contributor

ruanyl commented Nov 18, 2015

eslint_d doesn't work with vim if eslint and eslint plugins like 'eslint-plugin-react' are not installed locally. While use eslint, the linting works even eslint and it's plugins are installed globally.

@mantoni
Copy link
Owner

mantoni commented Nov 19, 2015

Thanks for reporting. This might be an unintended side effect of the last feature release. Looking into it. You can try and downgrade in the meantime.

@mantoni
Copy link
Owner

mantoni commented Nov 19, 2015

Ok, so this is not a bug. eslint_d must be able to require('eslint')`. It will always fall back to it's own dependency in case there is no local installation. Once eslint was required, it's up to eslint to load any plugins.

I'm not sure whether I can help improve this for you. However, you could create a local symlink to your global modules with npm link eslint-plugin-react.

@ruanyl
Copy link
Contributor Author

ruanyl commented Nov 19, 2015

@mantoni thank your for your answer. I use nvm as node version manager, would this be the issue? I will try to test more.

@mantoni
Copy link
Owner

mantoni commented Nov 19, 2015

No, nvm shouldn't make a difference. That's fine.

@ruanyl
Copy link
Contributor Author

ruanyl commented Nov 19, 2015

A bit findings after digging into this problem.

➜  js-reader git:(master) ✗ eslint_d lib/generator.js
Error: Cannot find module 'eslint' from '/path/to/project/js-reader'

I first run this in the root dir of my project(no eslint installed locally), eslint_d actually not load eslint it has.

Then I found this line of code: https://github.com/mantoni/eslint_d.js/blob/master/lib/linter.js#L29
The dir already changed before loading eslint, I guess that's why it cannot find the module.

My guess:
Since the dir changed, and eslint is programmably used here, if eslint-plugin-* are not installed locally in the dir, it will throw the cannot find module xxx error.

@yuezk
Copy link
Contributor

yuezk commented Nov 20, 2015

I have the same issue and I found that the resolve.sync module will not return null if module not found, instead, it will throw an error. So we should wrap it into a try ... catch` clause. PR #18 has already pushed.

@mantoni
Copy link
Owner

mantoni commented Nov 20, 2015

Thanks for looking into it! I’ve published v2.3.2 with @yuezk’s patch.
@ruanyl Can you confirm that this fixes the issue for you as well?

@ruanyl
Copy link
Contributor Author

ruanyl commented Nov 20, 2015

@mantoni, thank you @yuezk, it fixed the problem of resolving eslint.

@mantoni mantoni closed this as completed Nov 20, 2015
@sayandcode
Copy link

For me it helped when I restarted eslint_d using eslint_d restart. This related answer helped me.

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

4 participants