'eslint' is not recognized as an internal

2019-03-13 20:24发布

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 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

2条回答
贪生不怕死
2楼-- · 2019-03-13 20:27

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 .\
查看更多
手持菜刀,她持情操
3楼-- · 2019-03-13 20:34

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

it solves my problem.

查看更多
登录 后发表回答