Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module '../lib/cli' #6983

Closed
ghost opened this issue Aug 26, 2016 · 15 comments
Closed

Error: Cannot find module '../lib/cli' #6983

ghost opened this issue Aug 26, 2016 · 15 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion question This issue asks a question about ESLint

Comments

@ghost
Copy link

ghost commented Aug 26, 2016

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
  }
}
@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Aug 26, 2016
@kaicataldo
Copy link
Member

Hey, could you let us know where you're getting this output from? Is that from the command line or some sort of log in ST3?

@ghost
Copy link
Author

ghost commented Aug 27, 2016

@kaicataldo This is from ST3 debug log

@mysticatea
Copy link
Member

mysticatea commented Aug 27, 2016

Is this reproduced outside of Dropbox?

@ghost
Copy link
Author

ghost commented Aug 27, 2016

@mysticatea Yes, I have tried to move the project outside of Dropbox and the error still occurs.

@mysticatea
Copy link
Member

Ah, sorry.
My intention is "could you confirm that Dropbox sync behavior doesn't break installed eslint files?".
I don't think eslint throws that error before someone breaks the code of eslint.

@ghost
Copy link
Author

ghost commented Aug 27, 2016

Hi @mysticatea All of the files in my local dropbox folder, I don't know why those files will be broken?

@mysticatea
Copy link
Member

mysticatea commented Aug 27, 2016

I'm not sure why those files will be broken, too.
It's the reason I asked: "Is this reproduced outside of Dropbox?".

If it's reproduced outside of Dropbox, I don't have another idea. :/

@kaicataldo
Copy link
Member

kaicataldo commented Aug 27, 2016

I actually found a reproduction case for this (totally coincidentally, while working on a personal project). I get the exact same error when I copy a project directory (including its node_modules) and try to run the local ESLint installation from the copied directory. rm -rfing node_modules and npm i again in the copied directory fixes it.

Sounds like maybe something Dropbox is doing is causing a similar issue?

@wellyshen Can you confirm this does or doesn't happen when the project directory is outside of your Dropbox directory?

@kaicataldo kaicataldo added question This issue asks a question about ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Aug 27, 2016
@ghost
Copy link
Author

ghost commented Aug 28, 2016

@kaicataldo Yes, I am doing the same thing, I move my project out of my Dropbox folder. And reinstall the node_modules. Now I am observe if the error will happen or not.

@nzakas
Copy link
Member

nzakas commented Sep 1, 2016

@ghost does that fix your problem?

@vitorbal
Copy link
Member

vitorbal commented Oct 3, 2016

ping @ghost, any chance you could give us an update if your problem is fixed? Thanks!

@vitorbal
Copy link
Member

Closing, as there has been no updates from the author in more than 40 days.

@rschamp
Copy link

rschamp commented Nov 24, 2016

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 of bin/eslint.js. Then when you run eslint, it tries to require('../lib/cli') relative to node_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 and npm test there): https://github.com/LLK/eslint-config-scratch. I'm using npm v3.10.8.

@cyrus-and
Copy link

cyrus-and commented Dec 1, 2016

The point is that Dropbox doesn't properly sync symlinks. So if npm install has been executed on computer A and computer B receives node_modules via Dropbox, then computer B will end up with a broken node_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) then npm install again;

  • manually symlink the executables (e.g., ln -s ../eslint/bin/eslint.js node_modules/.bin/eslint).

This thing is incredibly annoying...

@rschamp
Copy link

rschamp commented Dec 2, 2016

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.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion question This issue asks a question about ESLint
Projects
None yet
Development

No branches or pull requests

7 participants