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

The instructions didn't work for me as-is #6

Open scbrady opened 6 years ago

scbrady commented 6 years ago

In order to get my React-Native project running, I had to do two extra things that aren't written in the readme:

  1. Add the metro-bundler package to the native project: yarn add --dev metro-bundler
  2. Add an empty object for the config param in rn-cli.config.js
    const getConfig = require('metro-bundler-config-yarn-workspaces')
    module.exports = getConfig(__dirname, {})

    Otherwise, I would get Cannot read property 'nodeModules' of undefined.

I can sent a PR if these are legitimate issues and if they weren't specific to my use case.

dariocravero commented 6 years ago

Is your project made using create react native app or react native's cli?

scbrady commented 6 years ago

@dariocravero It was using create react native app

bcarroll22 commented 6 years ago

Also along these lines, jest cannot be run from within the native app.

dariocravero commented 6 years ago

@scbrady I just realised that your issue was that getConfig doesn't have a default for the options object, sorry about that. Could you try v1.0.2? I just released a fix with default options on it. Also, do you still need metro-bundler? I tried the process again and didn't need to install it.

Thanks!

dariocravero commented 6 years ago

@bcarroll22 what errors are you seeing?

scbrady commented 6 years ago

@dariocravero Thanks, I no longer have to provide the empty object now. But I do still need metro-bundler, if I take it out, I get this error: Error: Cannot find module 'metro-bundler/src/blacklist'

And as far as jest goes, there are a lot of errors that come up, I tried getting it to work for hours last night.

At first, you get this: Error: Cannot find module '/Users/asdf/Documents/Code/referral/native/node_modules/jest/bin/jest.js' But you can fix it by changing the test script: "test": "node ../node_modules/jest/bin/jest.js"

Then you get this: Module <rootDir>/node_modules/jest-expo/src/setup.js in the setupFiles option was not found. And there are multiple ways to get around this, but even when you do, you end up at this error: Cannot find module 'setupDevtools' from 'setup.js' I couldn't get past that error reliably.

This is the best description of the problem that I found: https://github.com/facebook/react-native/issues/17469

nick-michael commented 6 years ago

Just seen this thread - I made an issue the other day regarding the 'metro-bundler' issue: #10

It seems like create react app installs metro-bundler into the 'metro' folder. Installing metro-bundler manually is the workaround I'm using for now