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

Unable to resolve module *any* #14996

Closed
thedevdavid opened this issue Jul 13, 2017 · 6 comments
Closed

Unable to resolve module *any* #14996

thedevdavid opened this issue Jul 13, 2017 · 6 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@thedevdavid
Copy link

If I install any package and import it, the packager stops with this Exception all the time.
There are some tips for what should I do, but it isn't working. Every time, I get this error, I trying all of the commands (below on screenshot) and react-native-git-upgrade, npm cache clean --force, npm cache verify, yarn cache clean in various order but it's a magic how it works... It's get resolved by one of these commands or all of them, or the order matters or who knows. The error magically disappears about 1-2 HOURS of trying.

It's really annoying that neither me or my team can not work when this error appears and as I search for it, I saw that this issue isn't resolved and it was an issue in 2015 too.

Many developers have tried a lot of possible solutions, but nobody can not solve it and it isn't depend on npm, node, react, react native, or any tool/package version.

Environment

  1. react-native -v: react-native-cli: 2.0.1 react-native: 0.43.2
  2. node -v: v8.1.3
  3. npm -v: 5.2.0
  4. yarn --version (if you use Yarn): 0.27.5
  • Target Platform: iOS & Android

  • Development Operating System: macOS Sierra 10.12.5

  • Build tools: Doesn't matter. With cli, xcode, and android studio.

Steps to Reproduce

  1. react-native init AppName
  2. npm install any-dependency
  3. react-native run-ios || run-android

Expected Behavior

Just compile, build and run my app.

Actual Behavior

simulator screen shot 2017 jul 13 11 00 44

@seanyusa
Copy link
Contributor

@DLevai94 Just to clarify, do you use yarn or npm?
Also are you restarting the packager after installing your dependency?

@thedevdavid
Copy link
Author

@seanyusa npm. Yes, I am restarting. As I think this issue is related mostly to package managing. Sometimes when I install X dependency by npm i --save x console say: "added 2 packages, removed 1"
and when I look after, it randomly deletes one of my packages. Sometimes this workaround is the best:
1 - close simulator/emulator
2 - stop packager
3 - terminal: rm -rf ./node_modules rm -fr package-lock.json npm install npm cache clean --force npm start -- --reset-cache

I think the root of this problem sits on the very deep of the bundle, packaging system of RN.

@hectoroso
Copy link

hectoroso commented Jul 16, 2017

I'm having what appears to be the same/similar issue. I have 0.45.1 projects I created a week or so ago where everything works fine, but now when I try to create projects:

react-native: react-native-cli: 2.0.1, react-native: 0.46.3
node: v6.11.1
npm: 2.15.11

All I do is run:

react-native init test
cd test
react-native run-ios

  • complains I don't have babel-core

npm install --save babel-core
react-native run-ios

I've also tried it where I install babel-core before i try run-ios. I've also tried react-native run-android, but same error.

I've tried the solutions it suggests, as well as what DLevai94 mentioned, but nothing works.
I've tried deleting node modules and changing the package.json to react-native 0.45.1 and rerunning npm install, but no luck. Very stuck at the moment.

screen shot 2017-07-16 at 1 26 07 am

@hectoroso
Copy link

hectoroso commented Jul 20, 2017

Just tried with npm version 3.10.10 and I no longer got the "Unable to resolve module" error. Also tried with node v8.2.0 and npm 5.3.0 and it worked. So for me maybe it had to do with the version of npm I used or its compatability with the version of node?

@hramos
Copy link
Contributor

hramos commented Sep 21, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@hramos hramos added the Icebox label Sep 21, 2017
@hramos hramos closed this as completed Sep 21, 2017
@thedevdavid
Copy link
Author

@hramos Thanks for taking care of it!

I found a temporary solution if anyone has this problem. It's maybe a problem of the package system.

After you initialize a new RN project, at the end of the fist npm install prints this message: Added 1 package, removed 628 (or some large number). It deletes a lot of packages.

This solves the problem when it appears: rm -rf ./node_modules && rm -fr package-lock.json && npm install && force npm start -- --reset-cache

I think if you use yarn, there's no error. Or after a react-native init you should do an npm install.

I hope I helped. There are a lot of issues opened about this problem, if you can link them to this comment, it will work for them too. 👍

@facebook facebook locked as resolved and limited conversation to collaborators Sep 21, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Sep 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants