BenoitZugmeyer / eslint-plugin-html

An ESLint plugin to extract and lint scripts from HTML files.
ISC License
430 stars 51 forks source link

eslint-plugin-html installed globally doesnt seem to work #10

Closed aponad closed 8 years ago

aponad commented 8 years ago

Hi, Using eslint-plugin-html locally it works fine, but if I try to install it globally eslint cannot find it.

Local install:

▶ ./node_modules/.bin/eslint app.vue    

/tmp/2/app.vue
  16:14  error  Parsing error: Unexpected identifier

✖ 1 problem (1 error, 0 warnings)
{
  "private": true,
  "dependencies": {
    "babel-eslint": "^4.1.4",
    "eslint": "^1.8.0",
    "eslint-config-airbnb": "^0.1.0",
    "eslint-plugin-html": "^1.1.0",
    "eslint-plugin-react": "^3.7.1"
  }
}

Global install:

▶ eslint app.vue                        
module.js:339
    throw err;
    ^

Error: Cannot find module 'eslint-plugin-html'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at /usr/local/lib/node_modules/eslint/lib/cli-engine.js:116:26
    at Array.forEach (native)
    at loadPlugins (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:107:21)
    at processText (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:194:5)
    at processFile (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:254:18)
    at executeOnFile (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:551:23)
▶ npm list --depth=0 -g             
/usr/lib
├── babel-eslint@4.1.3
├── bower@1.6.5
├── csslint@0.10.0
├── eslint@1.8.0
├── eslint-config-airbnb@0.1.0
├── eslint-plugin-html@1.1.0
├── eslint-plugin-react@3.6.3
├── grunt-cli@0.1.13
├── gulp@3.9.0
└── npm@2.14.7
▶ node -v
v4.2.2

.eslintrc:

{
  "plugins": [
    "html"
  ]
}
BenoitZugmeyer commented 8 years ago

Thank you for the report. Sadly, I can't reproduce your issue. Did you try to reinstall eslint and eslint-plugin-html ? Can you require("eslint-plugin-html"); when you execute nodejs in a directory without local node_modules?

This plugin is really straightforward and doesn't do anything fancy, it should work the same way other plugins do.

aponad commented 8 years ago

Hi, Thanks for your time, as it turned out my NODE_PATH was incorrect. Works like a charm now.

intcreator commented 7 years ago

I also installed eslint-plugin-html globally. What do you mean your NODE_PATH was incorrect?

aponad commented 7 years ago

@intcreator echo $NODE_PATH on Debian/Ubuntu it usually should be /usr/lib/node_modules

8ctopus commented 2 years ago

had same issue, fixed it with eslint . --resolve-plugins-relative-to=$(npm root -g) https://stackoverflow.com/a/68809128/10126479