viewstools / yarn-workspaces-cra-crna

How to use yarn workspaces with Create React App and Create React Native App (Expo) to share common code across
151 stars 23 forks source link

Instructions do not work with CRNA #1

Closed hassankhan closed 6 years ago

hassankhan commented 6 years ago
yarn start
yarn run v1.3.2
$ node link-workspaces.js
$ react-native-scripts start
20:00:09: Starting packager...
***ERROR STARTING PACKAGER***
Starting React Native packager...

ENOENT: no such file or directory, stat '/Users/hassankhan/Projects/workspace-project/packages/node_modules'
dariocravero commented 6 years ago

Can you share the failing repo? Thanks!

jpgarcia commented 6 years ago

Facing the same issue here. I found what is causing it and a workaround that do the trick:

Just replace a line in the metro-bundler-config-yarn-workspaces lib with the following:

// path.resolve(from, '..', 'node_modules'),
path.resolve(from, '..', '..', 'node_modules'),

I think this is because my workspaces are located inside a packages folder

Can we add a new parameter (maybe optional to keep it backward compatible) to the getConfig function in order to provide the node_modules root folder?

const app = path.resolve(__dirname)
const root = path.resolve(__dirname, '..', '..')

getConfig(app, root)

If you agree I can create a PR.

Thanks!

hassankhan commented 6 years ago

Apologies @dariocravero, haven't had time time to share a repo, but congratulations @jpgarcia for finding the root cause of the issue!

dariocravero commented 6 years ago

Hey @jpgarcia, yeah, if that sorts it for you guys, happy to take a PR in for it! I guess the idea would be that path.resolve(from, '..', 'node_modules') is a default for a nodeModules param, right? Maybe that can be an object as the second argument getConfig? Thanks!

Connorelsea commented 6 years ago

I tried making these changes in my project, following @jpgarcia's advice but still end up with this. Any idea what it could be?

Putting debug comments in rn-cli.config.js seems to generate the correct paths, so why still failing with seemingly no error?

Edit: This is a link to the repo where I am having trouble in the native package https://github.com/Connorelsea/remix-platform

image

image

Connorelsea commented 6 years ago

Eventually got this working using @jpgarcia's instructions. Nice work, would love a PR

jpgarcia commented 6 years ago

Hey @dariocravero did you have time to look the PR I sent? any chances to get this merged?

Let me know if you have any feedback, thanks!

dariocravero commented 6 years ago

Amazing! Thanks @jpgarcia, merged!