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

example quirk: issue with adding dependencies to the library root #308

Open
brodycj opened this issue Apr 6, 2020 · 2 comments
Open

example quirk: issue with adding dependencies to the library root #308

brodycj opened this issue Apr 6, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@brodycj
Copy link
Owner

brodycj commented Apr 6, 2020

updated:

If a developer uses Yarn to add any dependencies to the library root (not the example), the resulting library root node_modules would cause the example app to crash.

Recommended workaround solutions:

  • always stop Metro if running and remove node_modules from the library root after adding library dependencies and before running the example (it may be required to do yarn in the example to update the node_modules there)
  • consider manually adding any library root dependencies to the library root peerDependencies and devDependencies then using Yarn to add such dependencies to the example itself

This issue was originally reported on the interactive CLI tool in brodycj/react-native-module-init#42.

original description If I would create a library module with an example, run the example, add a dependency such a `prop-types` to the library root (not the example), and then try running again, then the app will crash. I think the bundler will show some error output at this point.

The workaround is to remove node_modules from the library root, restart Metro, then reinstall and restart the app.

I think this issue needs to be documented and investigated further.

@brodycj brodycj added the bug Something isn't working label Apr 6, 2020
@brodycj brodycj changed the title Workaround needed when adding dependencies to the library root example quirk: issue with adding dependencies to the library root Apr 7, 2020
brodycj added a commit that referenced this issue Apr 7, 2020
(issue #308 - issue with adding dependencies to the library root)

with other minor example log updates
brodycj added a commit that referenced this issue Apr 7, 2020
(issue #308 - issue with adding dependencies to the library root)

with other minor example log updates
@ngocdh383
Copy link

I got the same error and it worked when I removed react-native inside the devDependencies of the root library (not the example). Then I can run my application with dependencies, devDependencies, and peerDependencies in root library by installing node_modules for the root library and example.

@cunneen
Copy link

cunneen commented Jan 15, 2021

Oh thanks for reporting this @brodybits, I feel like I've been banging my head against a wall all day. If you hadn't logged the above, I'd still be doing the same. I love the create-react-native-module tool by the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants