question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plugins fail to load when eslint is installed globally

See original GitHub issue

I’ve authored a plugin eslint-no-exclusive-tests that warns if certain Jasmine methods are used (ddescribe, iit etc.)

When eslint is installed globally (as normal), a module loader error is thrown:

❯ eslint spec.js

module.js:340
    throw err;
          ^
Error: Cannot find module 'eslint-plugin-no-exclusive-tests'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at /usr/local/lib/node_modules/eslint/lib/cli-engine.js:122:26
    at Array.forEach (native)
    at loadPlugins (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:115:21)
    at processFile (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:151:9)
    at /usr/local/lib/node_modules/eslint/lib/cli-engine.js:222:30
    at walk (/usr/local/lib/node_modules/eslint/lib/util/traverse.js:82:9)

As the docs say to add eslint as a peerDependency, it gets installed locally to the project. If using the local eslint, the plugin runs as expected:

❯ ./node_modules/.bin/eslint spec.js

spec.js
   3:0   error  Unexpected ddescribe                       no-exclusive-tests/no-exclusive-tests

package.json:

...
  "devDependencies": {
    "eslint": "^0.8.0",
    "eslint-plugin-no-exclusive-tests": "^0.2.0"
...

.eslintrc

plugins:
  - no-exclusive-tests
rules:
  no-exclusive-tests/no-exclusive-tests: 2

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:38 (18 by maintainers)

github_iconTop GitHub Comments

11reactions
mysticateacommented, Feb 10, 2016
5reactions
huangyingjiecommented, Sep 11, 2015

Hi all, I ran into this issue on vim with ‘syntastic’. Since I have to use local eslint, the following is my vim config:

let local_eslint = finddir('node_modules', '.;') . '/.bin/eslint'
if matchstr(local_eslint, "^\/\\w") == ''
    let local_eslint = getcwd() . "/" . local_eslint
endif
if executable(local_eslint)
    let g:syntastic_javascript_eslint_exec = local_eslint
endif

Now the effect between vim and ‘npm run eslint’ is exactly the same.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to load plugin 'import' declared in '... » eslint-config ...
I've tried setting it up through eslint --init, uninstalling eslint globally and having all the packages locally, installing each package ...
Read more >
Getting Started with ESLint - Pluggable JavaScript Linter
ESLint is completely pluggable, every single rule is a plugin and you can add ... It is also possible to install ESLint globally...
Read more >
eslint/eslint - Gitter
If ESLint is installed globally, then make sure eslint-plugin-promise is also installed globally. A globally-installed ESLint cannot find a locally-installed ...
Read more >
Error: Failed to load plugin declared in '.eslintrc' : WEB-44691
ESLint is installed globally. An ESLint plugin (for example 'eslint-plugin-fp') is also installed globally. In WebStorm preferences — manually configured ...
Read more >
eslint-plugin-jest - npm
Installation. yarn add --dev eslint eslint-plugin-jest. Note: If you installed ESLint globally then you must also install eslint-plugin-jest ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found