eslint: Error: Cannot find module '../lib/cli'
I am using eslint v3.3.1 with Sublime text 3 to develop my react web app. Currently I encounter an error say :
Error: Cannot find module '../lib/cli'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/Welly/Dropbox/GitHub/react-universal-starter/node_modules/.bin/eslint:29:11)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
And when I remove and re-install node_modules, this error seems to be solved, but next time I launch my code editor this error occurs again, does anyone has this problem?
Here’s my .eslintrc :
{
"parser": "babel-eslint",
"extends": "airbnb",
"plugins": [
"react"
],
"env": {
"es6": true,
"browser": true,
"node": true
},
"rules": {
"global-require": 0,
"no-underscore-dangle": 0,
"no-console": 0,
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }]
},
"globals": {
"__DEV__": true,
"webpackIsomorphicTools": true
}
}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (8 by maintainers)
Yes, it does occur with other modules. After I posted that, the same thing happened with
tap
. The thing is that I only use Dropbox for backup, I don’t use the syncing behavior on multiple computers, and yet Dropbox apparently destroys the symlinks even then.Even more annoying to me after some Googling to see that Dropbox has had this issue for years and years. Ironic because a lot of their user base must be developers.
This happens to me and my team occasionally — the root cause seems to be that somewhere along the line
node_modules/.bin/eslint
has become a real file, a copy ofbin/eslint.js
. Then when you run eslint, it tries torequire('../lib/cli')
relative tonode_modules/.bin/
which crashes with this error. Uninstalling and reinstalling eslint fixes the issue, as it fixes.bin/eslint
to be a symlink again, but I wonder if some combination of dependencies causes this to happen?This just happened to me while working on this repo (i.e. running
npm install
andnpm test
there): https://github.com/LLK/eslint-config-scratch. I’m using npm v3.10.8.The point is that Dropbox doesn’t properly sync symlinks. So if
npm install
has been executed on computer A and computer B receivesnode_modules
via Dropbox, then computer B will end up with a brokennode_modules
folder where symlinks have been replaced with regular copies.This doesn’t happen with ESLint only, it impacts every Node.js module which provides at least one executable which relies on relative paths.
Possible solutions:
delete such modules only (e.g.,
rm -fr node_modules/eslint
) thennpm install
again;manually symlink the executables (e.g.,
ln -s ../eslint/bin/eslint.js node_modules/.bin/eslint
).This thing is incredibly annoying…