After installing ESLint through NPM, I'm getting the following error in my browser:
Error: Cannot find module 'eslint/lib/rules/no-unused-expressions' Referenced from:
Any idea what could cause this and how I can fix it?
After installing ESLint through NPM, I'm getting the following error in my browser:
Error: Cannot find module 'eslint/lib/rules/no-unused-expressions' Referenced from:
Any idea what could cause this and how I can fix it?
Try these steps:
In case you want to have eslint, try checking if you have in your devDependencies the line below:
"eslint": "5.6.0"
I had this issue while using a create-react-app. React scripts already come with an eslint version installed and that means you shouldn't need to install eslint on your own. I fixed this issue by doing the following:
npm installnpm start and everything was working fine againDeleted node-modules folder
Deleted my package-lock.json file
Removed eslint from the package.json file
Installed all packages again
npm install
npm start
and everything was working fine again
Easy fix #1
npm i -D --save eslint-loader
Easy fix #2
npm i -D --save eslint@5.16.0
Explanation:
eslint-loader/index.js (so not eslint). eslint-loader and check the version in its package.json. It's probably quite outdated. Mine was at 1.9.0, while the current version of eslint-loader is 4.0.2eslint/lib/formatters/stylish to eslint/lib/formatters/<some-other-folder>/stylish in a newer version of eslint (I think v6). And now this older eslint-loader version is failing to find the updated path in eslint.So either upgrading eslint-loader to a newer version that knows this new path (Easy fix 1), or downgrading eslint down to when it had that old path (Easy fix 2), should both work.
For the record I think this outdated dependency is coming from webpack, which makes it difficult to debug for the create-react-app folks.
Make sure you clean your node_modules. Delete your package-lock.json. and run the
npm cache clean --force to clean the cache.
Now install the eslint by running below in the directory:
npm i --save eslint
I know it's late to answer, maybe it's gonna help someone who comes to this thread.
for linux user and using npx just type npx eslint --init as the documentation says