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

Can't install / run in Yarn workspace #340

Closed
robdonn opened this issue Aug 2, 2017 · 8 comments
Closed

Can't install / run in Yarn workspace #340

robdonn opened this issue Aug 2, 2017 · 8 comments

Comments

@robdonn
Copy link

robdonn commented Aug 2, 2017

Description

When I create a Yarn workspace and try to use create-react-native-app in it it installs all of the initial dependencies and hoists them to the root directory, but then it errors.

If I create the app in another folder outside of the project and copy/paste the contents back into the workspace and run yarn install everything seems to run ok, but then yarn start doesn't work.

Expected Behavior

Running create-react-native-app in a Yarn workspace should install and run without errors with hoisted dependencies

Observed Behavior

Using package manager as yarnpkg with yarn interface.                                               
Installing packages. This might take a couple minutes.                                              
Installing react-native-scripts...                                                                  
                                                                                                    
yarn add v0.27.5                                                                                    
info No lockfile found.                                                                             
[1/4] Resolving packages...                                                                         
warning react-native-scripts > xdl > auth0-js > xtend > [email protected]:                          
[2/4] Fetching packages...                                                                          
[3/4] Linking dependencies...                                                                       
warning "[email protected]" has unmet peer dependency "react@^0.14.0 || ^15.0.0-0 || ^16.0.0-0".    
[4/4] Building fresh packages...                                                                    
success Saved lockfile.                                                                             
success Saved 296 new dependencies.                                                                 
├─ @ccheever/[email protected]                                                                           
├─ @expo/[email protected]                                                                              
├─ @expo/[email protected]                                                                            
├─ @expo/[email protected]                                                                            
├─ @expo/[email protected]                                                                          
├─ @segment/[email protected]                                                            
├─ [email protected]                                                                                    
├─ [email protected]                                                                                       
├─ [email protected]                                                                             
├─ [email protected]                                                                               
├─ [email protected]                                                                                 
├─ [email protected]                                                                                
├─ [email protected]                                                                                
├─ [email protected]                                                                              
├─ [email protected]                                                                                       
├─ [email protected]                                                                                       
├─ [email protected]                                                                                
├─ [email protected]                                                                                      
├─ [email protected]                                                                                   
├─ [email protected]                                                                                   
├─ [email protected]                                                                                      
├─ [email protected]                                                                                  
├─ [email protected]                                                                                       
├─ [email protected]                                                                             
├─ [email protected]                                                                             
├─ [email protected]                                                                                     
├─ [email protected]                                                                                  
├─ [email protected]                                                                               
├─ [email protected]                                                                               
├─ [email protected]                                                                                  
├─ [email protected]                                                                               
├─ [email protected]                                                                                      
├─ [email protected]                                                                            
├─ [email protected]                                                                 
├─ [email protected]                                                                                      
├─ [email protected]                                                                                   
├─ [email protected]                                                                                 
├─ [email protected]                                                                                  
├─ [email protected]                                                                                      
├─ [email protected]                                                                                
├─ [email protected]                                                                                 
├─ [email protected]                                                                                  
├─ [email protected]                                                                                      
├─ [email protected]                                                                                         
├─ [email protected]                                                                              
├─ [email protected]                                                                                 
├─ [email protected]                                                                            
├─ [email protected]                                                                                 
├─ [email protected]                                                                          
├─ [email protected]                                                                             
├─ [email protected]                                                                                 
├─ [email protected]                                                                              
├─ [email protected]                                                                        
├─ [email protected]                                                                               
├─ [email protected]                                                                           
├─ [email protected]                                                                                     
├─ [email protected]                                                                                  
├─ [email protected]                                                                                    
├─ [email protected]                                                                               
├─ [email protected]                                                                        
├─ [email protected]                                                                                
├─ [email protected]                                                                                  
├─ [email protected]                                                                               
├─ [email protected]                                                                                  
├─ [email protected]                                                                                      
├─ [email protected]                                                                                    
├─ [email protected]                                                                                  
├─ [email protected]                                                                                
├─ [email protected]                                                                             
├─ [email protected]                                                                                       
├─ [email protected]                                                                                    
├─ [email protected]                                                                                   
├─ [email protected]                                                                                   
├─ [email protected]                                                                        
├─ [email protected]                                                                                   
├─ [email protected]                                                                                  
├─ [email protected]                                                                                  
├─ [email protected]                                                                                  
├─ [email protected]                                                                                
├─ [email protected]                                                                       
├─ [email protected]                                                                                       
├─ [email protected]                                                                                 
├─ [email protected]                                                                               
├─ [email protected]                                                                                   
├─ [email protected]                                                                                     
├─ [email protected]                                                                            
├─ [email protected]                                                                                 
├─ [email protected]                                                                                      
├─ [email protected]                                                                                    
├─ [email protected]                                                                                  
├─ [email protected]                                                                               
├─ [email protected]                                                                              
├─ [email protected]                                                                                  
├─ [email protected]                                                                                 
├─ [email protected]                                                                                  
├─ [email protected]                                                                             
├─ [email protected]                                                                                      
├─ [email protected]                                                                                   
├─ [email protected]                                                                                
├─ [email protected]                                                                                   
├─ [email protected]                                                                                    
├─ [email protected]                                                                                       
├─ [email protected]                                                                               
├─ [email protected]                                                                                 
├─ [email protected]                                                                              
├─ [email protected]                                                                                  
├─ [email protected]                                                                                   
├─ [email protected]                                                                                     
├─ [email protected]                                                                                       
├─ [email protected]                                                                                      
├─ [email protected]                                                                    
├─ [email protected]                                                                                   
├─ [email protected]                                                                                
├─ [email protected]                                                                             
├─ [email protected]                                                                                
├─ [email protected]                                                                              
├─ [email protected]                                                                                   
├─ [email protected]                                                                                   
├─ [email protected]                                                                                   
├─ [email protected]                                                                          
├─ [email protected]                                                                                  
├─ [email protected]                                                                                         
├─ [email protected]                                                                                  
├─ [email protected]                                                                    
├─ [email protected]                                                                              
├─ [email protected]                                                                                 
├─ [email protected]                                                                                  
├─ [email protected]                                                                              
├─ [email protected]                                                                              
├─ [email protected]                                                                                    
├─ [email protected]                                                                                    
├─ [email protected]                                                                                      
├─ [email protected]                                                                           
├─ [email protected]                                                                                   
├─ [email protected]                                                                                      
├─ [email protected]                                                                                       
├─ [email protected]                                                                             
├─ [email protected]                                                                                  
├─ [email protected]                                                                                       
├─ [email protected]                                                                                  
├─ [email protected]                                                                              
├─ [email protected]                                                                                
├─ [email protected]                                                                      
├─ [email protected]                                                                        
├─ [email protected]                                                                                      
├─ [email protected]                                                                                   
├─ [email protected]                                                                                    
├─ [email protected]                                                                                      
├─ [email protected]                                                                                 
├─ [email protected]                                                                               
├─ [email protected]                                                                                     
├─ [email protected]                                                                                        
├─ [email protected]                                                                                        
├─ [email protected]                                                                                       
├─ [email protected]                                                                                 
├─ [email protected]                                                                                
├─ [email protected]                                                                                    
├─ [email protected]                                                                               
├─ [email protected]                                                                           
├─ [email protected]                                                                                 
├─ [email protected]                                                                                  
├─ [email protected]                                                                              
├─ [email protected]                                                                                     
├─ [email protected]                                                                                
├─ [email protected]                                                                          
├─ [email protected]                                                                                    
├─ [email protected]                                                                                   
├─ [email protected]                                                                                
├─ [email protected]                                                                                       
├─ [email protected]                                                                                   
├─ [email protected]                                                                                  
├─ [email protected]                                                                                   
├─ [email protected]                                                                             
├─ [email protected]                                                                                     
├─ [email protected]                                                                                    
├─ [email protected]                                                                                      
├─ [email protected]                                                                                         
├─ [email protected]                                                                                
├─ [email protected]                                                                                         
├─ [email protected]                                                                                         
├─ [email protected]                                                                                        
├─ [email protected]                                                                                 
├─ [email protected]                                                                                 
├─ [email protected]                                                                                 
├─ [email protected]                                                                              
├─ [email protected]                                                                                
├─ [email protected]                                                                                
├─ [email protected]                                                                                       
├─ [email protected]                                                                                    
├─ [email protected]                                                                                        
├─ [email protected]                                                                                  
├─ [email protected]                                                                                 
├─ [email protected]                                                                                   
├─ [email protected]                                                                                
├─ [email protected]                                                                                  
├─ [email protected]                                                                                
├─ [email protected]                                                                           
├─ [email protected]                                                                             
├─ [email protected]                                                                            
├─ [email protected]                                                                                       
├─ [email protected]                                                                             
├─ [email protected]                                                                                     
├─ [email protected]                                                                       
├─ [email protected]                                                                                   
├─ [email protected]                                                                              
├─ [email protected]                                                                                    
├─ [email protected]                                                                               
├─ [email protected]                                                                                 
├─ [email protected]                                                                                  
├─ [email protected]                                                                                   
├─ [email protected]                                                                           
├─ [email protected]                                                                                         
├─ [email protected]                                                                                
├─ [email protected]                                                                               
├─ [email protected]                                                                                   
├─ [email protected]                                                                       
├─ [email protected]                                                                                
├─ [email protected]                                                                                 
├─ [email protected]                                                                            
├─ [email protected]                                                                              
├─ [email protected]                                                                                      
├─ [email protected]                                                                       
├─ [email protected]                                                                      
├─ [email protected]                                                                           
├─ [email protected]                                                                                   
├─ [email protected]                                                                                    
├─ [email protected]                                                                                
├─ [email protected]                                                                             
├─ [email protected]                                                                                     
├─ [email protected]                                                                                  
├─ [email protected]                                                                         
├─ [email protected]                                                                                    
├─ [email protected]                                                                                
├─ [email protected]                                                                        
├─ [email protected]                                                                                     
├─ [email protected]                                                                                      
├─ [email protected]                                                                              
├─ [email protected]                                                                              
├─ [email protected]                                                                               
├─ [email protected]                                                                             
├─ [email protected]                                                                            
├─ [email protected]                                                                              
├─ [email protected]                                                                                
├─ [email protected]                                                                                     
├─ [email protected]                                                                                    
├─ [email protected]                                                                                 
├─ [email protected]                                                                                       
├─ [email protected]                                                                        
├─ [email protected]                                                                                 
├─ [email protected]                                                                                     
├─ [email protected]                                                                                   
├─ [email protected]                                                                             
├─ [email protected]                                                                               
├─ [email protected]                                                                               
├─ [email protected]                                                                                 
├─ [email protected]                                                                           
├─ [email protected]                                                                                 
├─ [email protected]                                                                             
├─ [email protected]                                                                                  
├─ [email protected]                                                                          
├─ [email protected]                                                                                     
├─ [email protected]                                                                                        
├─ [email protected]                                                                                
├─ [email protected]                                                                                    
├─ [email protected]                                                                                 
├─ [email protected]                                                                                    
├─ [email protected]                                                                                 
├─ [email protected]                                                                                       
├─ [email protected]                                                                                       
├─ [email protected]                                                                               
├─ [email protected]                                                                                  
├─ [email protected]                                                                                       
├─ [email protected]                                                                               
├─ [email protected]                                                                                 
├─ [email protected]                                                                                   
├─ [email protected]                                                                              
├─ [email protected]                                                                               
├─ [email protected]                                                                                     
├─ [email protected]                                                                           
├─ [email protected]                                                                                 
├─ [email protected]                                                                                       
├─ [email protected]                                                                             
├─ [email protected]                                                                                
├─ [email protected]                                                                                       
├─ [email protected]                                                                                       
├─ [email protected]                                                                                     
├─ [email protected]                                                                               
├─ [email protected]                                                                                      
├─ [email protected]                                                                                    
├─ [email protected]                                  
├─ [email protected]                                                                                     
├─ [email protected]                                                                                       
├─ [email protected]                                                                                       
├─ [email protected]                                                                                      
├─ [email protected]                                                                                    
└─ [email protected]                                                                                      
Done in 12.96s.                                                                                     
(node:42384) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error:
 ENOENT: no such file or directory, open 'C:\robdonn\Personal\robdonn\test\apps\native\node_modules\
react-native-scripts\package.json'                                                                  
(node:42384) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the futur
e, promise rejections that are not handled will terminate the Node.js process with a non-zero exit c
ode.                                                                                                

Environment

Please run these commands in the project folder and fill in their results:

  • npm ls react-native-scripts:
[email protected] C:\robdonn\Personal\robdonn\test\apps\native
`-- (empty)
  • npm ls react-native:
[email protected] C:\robdonn\Personal\robdonn\test\apps\native
`-- (empty)
  • npm ls expo:
[email protected] C:\robdonn\Personal\robdonn\test\apps\native
`-- (empty)
  • node -v: v8.2.1
  • npm -v: 5.3.0
  • yarn --version: 0.27.5
  • watchman version: Please specify a target and action

Reproducible Demo

repro

@brentvatne
Copy link
Member

I'm not familiar with yarn workspaces yet, can you investigate and try to resolve? I won't have time to look into it for a bit.

@justinobney
Copy link

I have found that I can create it elsewhere, then move it (except node_modules) and then run yarn and it all installs.

I cant successfully run yarn start after that though, but I haven't had much time to dig in.

@MikeSuiter
Copy link

@justinobney did you ever get this to work? I'm starting on a big project where I'll have several common packages and also a couple of apps in packages that will use the common code and have yet to get it to work with CRA and yarn workspaces.

@DannyvanderJagt
Copy link

@justinobney How did you fix the hoisting of the native node_modules like 'react-native' etc (context: the react-native package must be in the node_modules inside your react-native project otherwise Xcode can't build / Xcode doesn't like symlinks ).

I didn't get it work without using lerna and ended up creating my own yarn installer script for now.

Note: There are people working on adding a nohoist option to yarn workspaces, yarnpkg/yarn#3882. This will allow us to prevent the hoisting of packages like react-native.

@dariocravero
Copy link

dariocravero commented Dec 2, 2017

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

@scottmas
Copy link

@brentvatne This still isn't working. It would be real nice if it could be resolved. I think all that needs to change is how Exp looks for react native.

@mekwall
Copy link

mekwall commented Apr 29, 2018

Please reopen since this is still a problem.

@robdonn
Copy link
Author

robdonn commented May 12, 2018

Hey everyone, I figure since I opened this issue then I should resolve it.

The trick is a recent feature of yarn workspaces, nohoist. The nohoist option allows you to specify packages/directories that you do not want to be hoisted.

root package.json

{
  "name": "your-monorepo",
  "version": "1.0.0",
  "private": true,
  "workspaces": {
    "packages": [
      "your-crna-app"
    ],
    "nohoist": [
      "**/react-native/**",
      "**/react-native",
      "**/react-native-scripts",
      "**/react-native-scripts/**",
      "**/expo",
      "**/expo/**"
    ]
  }
}

I hope this helps anyone out there. More info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants