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

Doesn't support a nested `packages` directory. #19

Open Kyle-Mendes opened 6 years ago

Kyle-Mendes commented 6 years ago

If you keep your individual packages in anything that's not top level, this approach doesn't seem to work.

// package.json
{
  "workspaces": {
    "packages": ["packages/*"]
  }
}
// directories
package.json
  |_ packages/
    |_ native/
    |_ web/

running yarn start in the native directory results in:

ENOENT: no such file or directory, stat '...PROJECT/packages/node_modules'
Metro Bundler process exited with code 1

moving native and web outside of packages solves this problem.

allforabit commented 6 years ago

Have you added the following to rn-cli.config.js:

const path = require('path');
const getConfig = require('metro-bundler-config-yarn-workspaces')

const options = { nodeModules: path.resolve(__dirname, '..', '..') }

module.exports = getConfig(__dirname, options)