Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'eslint' is not recognized as an internal or external command

I'm trying to install eslint & run it in vs code. I ran this command:

npm i -g eslint 

and it seemed to work, but I keep getting a "'eslint' is not recognized as an internal or external command" error when I try & run eslint. What gives?

http://eslint.org/docs/user-guide/command-line-interface

http://eslint.org/docs/user-guide/getting-started

like image 273
Mr Smith Avatar asked Jun 08 '16 14:06

Mr Smith


People also ask

Is not recognized as an internal or external command in Eslint?

"'eslint' is not recognized as an internal or external command, operable program or batch file". What gives? Use npm ls -g to get the location where your globals are being installed, then make sure that is in your PATH . On Windows, at least, that's a semi-common issue when first getting things setup...

How do I install Eslint locally?

If you haven't installed ESLint either locally or globally do so by running npm install eslint in the workspace folder for a local install or npm install -g eslint for a global install. On new folders you might also need to create a . eslintrc configuration file.

How do you fix Eslint?

There are three ways that ESLint fix can be run: eslint --fix. eslint --fix-dry-run. eslint --fix --fix-type.


2 Answers

The eslint module must not be installed into global.

instead, you should install eslint-cli module into global.

So, first install eslint-cli gloablly:

npm -g i eslint-cli 

then in the project folder: install eslint locally

npm i eslint --save-dev 

Then in the project folder you can run someting like: (on Windows)

eslint .\ 
like image 174
Felix Avatar answered Sep 16 '22 18:09

Felix


Well, if you are a Windows user and installing eslint-cli not working for you, try using:

node node_modules\eslint\bin\eslint.js --init 

Or, you can use npx which lets you run commands locally node_modules/.bin

npx eslint --init 

If you yarn you can just use:

yarn eslint --init 

Note:

1- This answer is updated to include yarn and npx. 2- This issue is releated to modules loclly insalled.

like image 21
Jalal Avatar answered Sep 17 '22 18:09

Jalal