polygonplanet / sublime-text-eslint

ESLint any JavaScript file in Sublime Text
24 stars 7 forks source link

how let this plugin use current project eslint, not global envirment #20

Closed videni closed 6 years ago

videni commented 6 years ago

I have install eslint in my project, but when run eslint, it says

Error: Cannot find module 'eslint'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)

I never use this plugin in sublime text successfully.

  1. it should use current project eslint settings , including rules and all other eslint plugins, because different project may have different plugins enabled
polygonplanet commented 6 years ago

I tried:

$ mkdir test
$ npm init
$ echo 'var var a;' >> test.js
$ npm install eslint

Open test.js in sublime text and run eslint. It works in node v9.3.0, and this plugin v5.0.1. What is your node's version?

videni commented 6 years ago

@polygonplanet I am using

node v8.11.1
 this plugin v5.0.1.
polygonplanet commented 6 years ago

I tried on node v8.11.1, and it worked. Refer https://github.com/polygonplanet/sublime-text-eslint/issues/9#issuecomment-339619133

buokae commented 6 years ago

I have the same issue, this module seems to rely on either some environment variable that I don't have or some setting I miss in Sublime Text or something else. I use create-react-app, and I just upgraded to the latest version (which includes eslint 3.19.0). I 've tried setting "node_modules_path": "C:\\Users\\u\\AppData\\Roaming\\npm\\node_modules", in ESLint.sublime-settings, which doesn't work. I've also tried setting a NODE_PATH system variable with the value C:\Program Files\nodejs, which also didn't work. I've also tried adding "node_path": "C:\\Program Files\\nodejs", to ESLint.sublime-settings, which also didn't work.

Have latest versions of everything (exept perhaps a half year old nodejs).

module.js:491
    throw err;
    ^

Error: Cannot find module 'eslint'
    at Function.Module._resolveFilename (module.js:489:15)
    at Function.Module._load (module.js:439:25)
    at Module.require (module.js:517:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\u\AppData\Roaming\Sublime Text 3\Packages\ESLint\linter.js:21:12)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)
[Finished in 0.7s]