-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 './options' #2582
Comments
What do you get from the following commands?
|
Note that mocha is not installed as global package, it is only a dev dependency of the package and installing it globally is not an option. |
Hmm... What if you uninstall Mocha and reinstall it, as in #2423?
Yeah, we don't recommend global installs anyway. They interfere with local installs and cause confusion as to which version of Mocha is being run. |
Actually the hint form #2423 did work. After calling:
running tests via |
If you can figure out what triggers the |
I had the exact same problem. I found that my global mocha install worked correctly, but there was some kind of problem with my local install of mocha.
I resolved, by deleting 'mocha' and '_mocha' from my appdir/node_modules/.bin directory. |
I commented on the other issue #2423 ( my comment ) with some suggested fixes. Just wanted to let you know @ScottFreeCode |
I'm have the exact same issue. Can See the option file is there in the mocha bin folder still the error was coming.
I uninstalled it completely from local and there was no global mocha install, too on my system. Cleared npm cache too.
Further even after uninstall the
Seems like mocha Checking the long listing shows
After running npm install mocha again can see now symlink instead of the regular file and the test is running fine.
Both Mocha version is same for above case So i Tried checking in the old test that was written on some other system by other guys and saw there too it was the same regular file and it was not symlink and it too was throwing the same error when i ran it using
mocha
Current install created Symlink and earlier there was regular file. |
After doing Note: I also ensured I had mocha installed globally. |
I'd like to point out that this particular detail is an NPM issue rather than a Mocha issue, as Mocha does not control the removal of symlinks or scripts from
You removed the entry point of the local install and used the global install instead. However, we don't recommend using a global install of Mocha in the first place (there's no significant benefit known to us at this time -- even in this case, reinstalling the local copy should suffice instead -- and there is non-negligible risk that it will result in use of an outdated Mocha version and/or confusion as to which version of Mocha is actually being used). Also, deleting the files from I've had the chance to confirm that this issue can result from using So far I haven't come up with anything I think is a good idea. I've thought of a fairly wide variety of bad ones. Potential solutions vary in robustness, in helpfulness and in the assumptions they make about the package manager that's installing Mocha; I haven't come up with any that are more than marginally helpful, are robust and don't make any assumptions. One thing that has crossed my mind is that this potentially affects any (especially locally installed) CLI Node program (excepting Windows-only ones, if there even are any of those). Mocha might get hit by it more than others due to greater popularity, but to really resolve the issue in general you'd have to either have every Node CLI program handle this in some way or else change NPM's use of symlinks. So I wonder: is there some expected convention that other programs follow and Mocha just happens to be out of the ordinary for missing it? Or is this something that arguably ought to be fixed in NPM instead of every CLI program having to come up with a way to handle it? |
I am a bot that watches issues for inactivity. |
In case other poor souls find themselves here, I had this problem because I had globally installed mocha, and that globally installed module was missing its To resolve this problem I changed the following line in
to:
Because I could see |
My problem was the same, but the solution was slightly different since it wasn't a global install. Just putting this hear in case the above solution still perplexes people. I compared two of my existing apps (one that worked) to see what might be different about the .bin/mocha file...
notice the symlink? so inside the first app...
this solved my problem, but also made me think that I had broken symlinks all over the place... from the broken app...
from the working app...
Now I realized this was an ugly copy. So I started my copy over using...
so its an exact replica. This is still a pretty ugly thing to do, but it worked. |
when starting mocha the recommended way:
I get the following error:
the error goes away if I start
mocha
via:Here some system info:
The text was updated successfully, but these errors were encountered: