Closed mattfysh closed 6 years ago
Yea, we should really figure out a Workspaces integration. Also as a solution to the "absolute imports" problem.
@gaearon I tried to use require.resolve
within the current path.resolve
but couldn't get it working... granted I only had a couple of minutes to try, so I may not have used it right... feels like it should be an easy fix though - to get the script to use node's require
resolution algorithm.
PS. Thanks for the quick reply! 🚀
In case anyone is stuck with this and until the different issues are fixed, I made a little guide on how to use yarn workspaces with Create React App and Create React Native App (Expo) to share common code across. Hope you find it handy! https://learn.viewsdx.com/how-to-use-yarn-workspaces-with-create-react-app-and-create-react-native-app-expo-to-share-common-ea27bc4bad62 https://medium.com/viewsdx/how-to-use-yarn-workspaces-with-create-react-app-and-create-react-native-app-expo-to-share-common-ea27bc4bad62
@dariocravero - thats the workaround I've gone with, creating in a tmp location and copying into the yarn workspaces structure. In addition to removing node_modules, you may want to also remove yarn.lock as I believe with workspaces all package locks are managed in the top-level lockfile? I could be mistaken though, I came to this conclusion when running yarn outdated
in the repo root and having outdated dependencies inside nested packages appearing in the output. @gaearon - does that sound right?
That's a good point @mattfysh, thanks! Updated the guide :)
Seems like a duplicate of https://github.com/facebookincubator/create-react-app/issues/3031.
Is this a bug report?
Yes
Can you also reproduce the problem with npm 4.x?
No
Which terms did you search for in User Guide?
Environment
node -v
: v8.7.0npm -v
: 5.5.1yarn --version
(if you use Yarn): 1.2.1npm ls react-scripts
(if you haven’t ejected): N/A (happens on init)Then, specify:
Steps to Reproduce
(Write your steps here:)
mkdir cra-issue && cd cra-issue
yarn
create-react-app packages/app-a
Expected Behavior
A new CRA application to be initialized under
packages/app-a
Actual Behavior
Reproducible Demo
Use steps above