ESLint with more affordable global installation issues

I am in the process of setting up my ReactJS environment, and I am following FrontendMasters on this topic.

After installing eslint and prettier all over the world with a thread, the author runs this command eslint js\**\*.{js,jsx} And on his machine, all this is good, but I get the following:

Unfortunately! Something went wrong! :(

ESLint could not find the "eslint-plugin-prettier" plugin. This can happen for several reasons:

  1. If ESLint is installed globally, make sure that eslint-plugin-prettier is also installed globally. A globally installed ESLint cannot find a locally installed plugin.

  2. If ESLint is installed locally, it is likely that the plugin is not installed correctly. Try reinstalling by doing the following:

    npm i eslint-plugin-prettier @ latest --save-dev

If you still cannot figure out the problem, go to https://gitter.im/eslint/eslint to chat with the team.

I tried Google, but could not find anything suitable. Why is this happening? I am on Windows 10 using the latest version of Yarn (v0.24.6) and my eslintrc.json looks like this:

 { "extends": ["airbnb", "prettier", "prettier/react"], "plugins": ["prettier"], "parserOptions": { "ecmaVersion": 2016, "sourceType": "module", "ecmaFeatures": { "jsx": true } }, "env": { "es6": true, "browser": true, "node": true } } 

UPDATE

I followed the Daydream tips below, although I don't have nvm installed. But I really deleted the node_modules folder, and after talking to ESLint Gitter, I continued to delete ESLint and Prettier around the world. Then I did ESLint and Prettier devDependencies. In the end, I ran the yarn command to reinstall everything, and now I get this:

Image

Note : the project is open source and is located on GitHub, if you want to see for yourself.

+7
source share
7 answers

I am also doing a course, and the first tip I saw on the Internet was to access the direct path to eslint through a buckle installation in node_modules:

./node_modules/.bin/eslint **/*.{js,jsx} --quiet

But after that I got an error message with - Unexpected top-level property "ecmaFeatures"

Ultimately, I decided to eliminate node_modules, erase everything from ~/.nvm/versions/node/<the version>/lib/node_modules , except for the npm and yarn , and just typed yarn reinstall everything.

After that ./node_modules/.bin/eslint **/*.{js,jsx} --quiet worked fine (but I still had to specify the installation path.

Hope this helps!

0
source

I just came across the same question. This seems to be a problem with the newest version of eslint, mine was 4.2.0. To fix this, I:

  run: Yarn remove eslint or run: npm uninstall eslint 

this will delete it locally then

  run: yarn add eslint@3.19.0 or run: npm install eslint@3.19.0 run: eslint **/*.{js,jsx} --quiet 

My paths can be configured differently, so do this with the answer "Daydream Nation", you have to make it work. I'm not sure which version of os eslint Brian is using, and I'm sure that if you pull on one of your latest repos, this will tell you, but hopefully it helps you in the right direction.

0
source

I was missing a few packages. This is how I fixed it.

 npm i eslint-config-prettier -save-dev npm i eslint-config-standard -save-dev npm i eslint-plugin-node -save-dev npm i eslint-plugin-promise -save-dev 

Here is my package.json

 { "name": "rpp-react", "private": true, "scripts": { "start": "meteor run" }, "dependencies": { "babel-runtime": "^6.20.0", "meteor-node-stubs": "~0.2.4", "prop-types": "^15.5.10", "react": "^15.6.1", "react-addons-pure-render-mixin": "^15.6.0", "react-dom": "^15.6.1", "react-tap-event-plugin": "^2.0.1" }, "devDependencies": { "babel-eslint": "^8.0.0", "eslint": "^4.7.2", "eslint-config-prettier": "^2.5.0", "eslint-config-standard": "^10.2.1", "eslint-plugin-flowtype": "^2.35.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-node": "^5.1.1", "eslint-plugin-prettier": "^2.3.1", "eslint-plugin-promise": "^3.5.0", "eslint-plugin-react": "^7.3.0", "eslint-plugin-standard": "^3.0.1", "prettier": "^1.7.0" } } 

Here is my .eslintrc.json

 { "extends": [ "standard", "plugin:flowtype/recommended", "plugin:react/recommended", "prettier", "prettier/flowtype", "prettier/react", "prettier/standard" ], "plugins": [ "flowtype", "react", "prettier", "standard" ], "parserOptions": { "sourceType": "module", "ecmaFeatures": { "jsx": true } }, "env": { "es6": true, "node": true }, "rules": { "prettier/prettier": "error" } } 
0
source

Here you have installed the ESLint development dependency globally:

 sudo npm install --global eslint-plugin-react 

And install other development dependencies in the project directory.

  • eslint-config-prettier
  • eslint configurations respond
  • eslint-plugin-prettier
  • eslint responsive plugin

And ESLint cannot find these other development dependencies. Thus, you need to install all these development dependencies globally to solve this problem.

OR

Install all these development dependencies in the project directory and use the command:

 ~/<project_directory>/node_modules/.bin/eslint **/*.{js,jsx} --quiet 
0
source

This is UGLY HACK , but it was the only way for me ... to solve this problem. I used the strace tool to check which modules are needed, I copied these files (pacience at this point, please!), And it worked :)

 strace eslint --debug Person.js 

Yes ... you need to scroll through a few lines until you find something like this:

stat ("/usr/local/share/.config/yarn/global/ node_modules / eslint / node_modules / eslint-plugin-prettier", 0x7fff5c139db0) = -1 ENOENT (There is no such file or directory)

You need to COPY the necessary modules ... and it will work.

This is a list of modules that I had to manually copy (inside / usr / local / share / .config / yarn / global / node_modules / eslint / node_modules /)

 eslint-config-airbnb eslint-config-airbnb-base eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-prettier/node_modules/fast-diff eslint-plugin-react 

Please excuse my ugly English, I study :)

0
source

Add the dependency to .pre-commit-config.yaml file as an additional dependency.

0
source

I got the same error (β€œI can’t find the eslint-config-prettier / react module”) during the steps from the Frontend Masters course you mentioned and was able to resolve it by installing eslint-config-prettier , as shown below, before running the lint script :

 npm install --save-dev eslint-config-prettier 

or if yarn is used:

 yarn add --dev eslint-config-prettier 

Please note that eslint-config-prettier "disables all rules that are not needed or may conflict with prettier ones."

0
source

Source: https://habr.com/ru/post/1269326/


All Articles