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 > object-keys@0.4.0:                          
[2/4] Fetching packages...                                                                          
[3/4] Linking dependencies...                                                                       
warning "react-redux@5.0.5" 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/crayon@5.0.0                                                                           
├─ @expo/bunyan@1.8.10                                                                              
├─ @expo/json-file@5.3.0                                                                            
├─ @expo/osascript@1.8.0                                                                            
├─ @expo/spawn-async@1.3.0                                                                          
├─ @segment/loosely-validate-event@1.1.2                                                            
├─ accepts@1.3.3                                                                                    
├─ ajv@4.11.8                                                                                       
├─ analytics-node@2.4.1                                                                             
├─ ansi-escapes@2.0.0                                                                               
├─ ansi-regex@3.0.0                                                                                 
├─ ansi-styles@3.2.0                                                                                
├─ any-promise@1.3.0                                                                                
├─ array-flatten@1.1.1                                                                              
├─ asap@2.0.6                                                                                       
├─ asn1@0.2.3                                                                                       
├─ assert-plus@1.0.0                                                                                
├─ async@1.5.2                                                                                      
├─ asynckit@0.4.0                                                                                   
├─ auth0-js@7.6.1                                                                                   
├─ auth0@2.7.0                                                                                      
├─ aws-sign2@0.6.0                                                                                  
├─ aws4@1.6.0                                                                                       
├─ babel-runtime@6.25.0                                                                             
├─ balanced-match@1.0.0                                                                             
├─ Base64@0.1.4                                                                                     
├─ base64url@2.0.0                                                                                  
├─ bcrypt-pbkdf@1.0.1                                                                               
├─ block-stream@0.0.9                                                                               
├─ bluebird@2.11.0                                                                                  
├─ body-parser@1.17.2                                                                               
├─ boom@2.10.1                                                                                      
├─ brace-expansion@1.1.8                                                                            
├─ buffer-equal-constant-time@1.0.1                                                                 
├─ bytes@2.4.0                                                                                      
├─ callsite@1.0.0                                                                                   
├─ camel-case@1.2.2                                                                                 
├─ caseless@0.12.0                                                                                  
├─ chalk@2.0.1                                                                                      
├─ change-case@2.3.1                                                                                
├─ cli-cursor@2.1.0                                                                                 
├─ cli-width@2.1.0                                                                                  
├─ clone@2.1.1                                                                                      
├─ co@4.6.0                                                                                         
├─ color-convert@1.9.0                                                                              
├─ color-name@1.1.3                                                                                 
├─ combined-stream@1.0.5                                                                            
├─ commander@2.11.0                                                                                 
├─ component-emitter@1.2.1                                                                          
├─ component-type@1.2.1                                                                             
├─ concat-map@0.0.1                                                                                 
├─ constant-case@1.1.2                                                                              
├─ content-disposition@0.5.2                                                                        
├─ content-type@1.0.2                                                                               
├─ cookie-signature@1.0.6                                                                           
├─ cookie@0.3.1                                                                                     
├─ cookiejar@2.1.1                                                                                  
├─ core-js@2.4.1                                                                                    
├─ core-util-is@1.0.2                                                                               
├─ create-react-class@15.6.0                                                                        
├─ cross-spawn@5.1.0                                                                                
├─ cryptiles@2.0.5                                                                                  
├─ crypto-token@1.0.1                                                                               
├─ dashdash@1.14.1                                                                                  
├─ debug@2.6.7                                                                                      
├─ decache@4.1.0                                                                                    
├─ deep-diff@0.3.4                                                                                  
├─ delay-async@1.1.0                                                                                
├─ delayed-stream@1.0.0                                                                             
├─ depd@1.1.1                                                                                       
├─ destroy@1.0.4                                                                                    
├─ dot-case@1.1.2                                                                                   
├─ ecc-jsbn@0.1.1                                                                                   
├─ ecdsa-sig-formatter@1.0.9                                                                        
├─ ee-first@1.1.1                                                                                   
├─ encodeurl@1.0.1                                                                                  
├─ encoding@0.1.12                                                                                  
├─ es6-error@4.0.2                                                                                  
├─ escape-html@1.0.3                                                                                
├─ escape-string-regexp@1.0.5                                                                       
├─ etag@1.8.0                                                                                       
├─ exec-async@2.2.0                                                                                 
├─ exists-async@2.0.0                                                                               
├─ express@4.15.3                                                                                   
├─ extend@3.0.1                                                                                     
├─ external-editor@2.0.4                                                                            
├─ extsprintf@1.0.2                                                                                 
├─ fbjs@0.8.14                                                                                      
├─ figures@2.0.0                                                                                    
├─ file-type@4.4.0                                                                                  
├─ finalhandler@1.0.3                                                                               
├─ forever-agent@0.6.1                                                                              
├─ form-data@2.1.4                                                                                  
├─ formidable@1.1.1                                                                                 
├─ forwarded@0.1.0                                                                                  
├─ freeport-async@1.1.1                                                                             
├─ fresh@0.5.0                                                                                      
├─ fs-extra@3.0.1                                                                                   
├─ fs.realpath@1.0.0                                                                                
├─ fstream@1.0.11                                                                                   
├─ getpass@0.1.7                                                                                    
├─ glob@7.1.2                                                                                       
├─ graceful-fs@4.1.11                                                                               
├─ har-schema@1.0.5                                                                                 
├─ har-validator@4.2.1                                                                              
├─ has-color@0.1.7                                                                                  
├─ has-flag@2.0.0                                                                                   
├─ hasbin@1.2.3                                                                                     
├─ hawk@3.1.3                                                                                       
├─ hoek@2.16.3                                                                                      
├─ hoist-non-react-statics@1.2.0                                                                    
├─ home-dir@1.0.0                                                                                   
├─ http-errors@1.6.1                                                                                
├─ http-signature@1.1.1                                                                             
├─ iconv-lite@0.4.15                                                                                
├─ indent-string@3.2.0                                                                              
├─ inflight@1.0.6                                                                                   
├─ inherits@2.0.3                                                                                   
├─ inquirer@3.2.1                                                                                   
├─ instapromise@2.0.7-rc.1                                                                          
├─ invariant@2.2.2                                                                                  
├─ ip@1.1.5                                                                                         
├─ ipaddr.js@1.4.0                                                                                  
├─ is-fullwidth-code-point@2.0.0                                                                    
├─ is-lower-case@1.1.3                                                                              
├─ is-promise@2.1.0                                                                                 
├─ is-stream@1.1.0                                                                                  
├─ is-typedarray@1.0.0                                                                              
├─ is-upper-case@1.1.2                                                                              
├─ isarray@1.0.0                                                                                    
├─ isemail@2.2.1                                                                                    
├─ isexe@2.0.0                                                                                      
├─ isomorphic-fetch@2.2.1                                                                           
├─ isstream@0.1.2                                                                                   
├─ items@2.1.1                                                                                      
├─ joi@10.6.0                                                                                       
├─ join-component@1.1.0                                                                             
├─ js-tokens@3.0.2                                                                                  
├─ jsbn@0.1.1                                                                                       
├─ jschardet@1.5.0                                                                                  
├─ json-fallback@0.0.1                                                                              
├─ json-schema@0.2.3                                                                                
├─ json-stable-stringify@1.0.1                                                                      
├─ json-stringify-safe@5.0.1                                                                        
├─ json5@0.5.1                                                                                      
├─ jsonfile@2.4.0                                                                                   
├─ jsonify@0.0.0                                                                                    
├─ jsonp@0.0.4                                                                                      
├─ jsonschema@1.1.1                                                                                 
├─ jsonwebtoken@7.4.1                                                                               
├─ jsprim@1.4.0                                                                                     
├─ jwa@1.1.5                                                                                        
├─ jws@3.1.4                                                                                        
├─ klaw@1.3.1                                                                                       
├─ lodash-es@4.17.4                                                                                 
├─ lodash.once@4.1.1                                                                                
├─ lodash@4.17.4                                                                                    
├─ loose-envify@1.3.1                                                                               
├─ lower-case-first@1.0.2                                                                           
├─ lower-case@1.1.4                                                                                 
├─ lru-cache@4.1.1                                                                                  
├─ match-require@2.1.0                                                                              
├─ md5hex@1.0.0                                                                                     
├─ media-typer@0.3.0                                                                                
├─ merge-descriptors@1.0.1                                                                          
├─ methods@1.1.2                                                                                    
├─ mime-db@1.29.0                                                                                   
├─ mime-types@2.1.16                                                                                
├─ mime@1.3.4                                                                                       
├─ mimic-fn@1.1.0                                                                                   
├─ minimatch@3.0.4                                                                                  
├─ minimist@1.2.0                                                                                   
├─ mkdirp-promise@5.0.1                                                                             
├─ mkdirp@0.5.1                                                                                     
├─ moment@2.18.1                                                                                    
├─ mout@0.11.1                                                                                      
├─ ms@2.0.0                                                                                         
├─ mute-stream@0.0.7                                                                                
├─ mv@2.1.1                                                                                         
├─ mz@2.6.0                                                                                         
├─ ncp@2.0.0                                                                                        
├─ negotiator@0.6.1                                                                                 
├─ node-fetch@1.7.1                                                                                 
├─ oauth-sign@0.8.2                                                                                 
├─ object-assign@4.1.1                                                                              
├─ object-keys@0.4.0                                                                                
├─ on-finished@2.3.0                                                                                
├─ once@1.4.0                                                                                       
├─ onetime@2.0.1                                                                                    
├─ opn@4.0.2                                                                                        
├─ os-tmpdir@1.0.2                                                                                  
├─ param-case@1.1.2                                                                                 
├─ parseurl@1.3.1                                                                                   
├─ pascal-case@1.1.2                                                                                
├─ path-case@1.1.2                                                                                  
├─ path-exists@3.0.0                                                                                
├─ path-is-absolute@1.0.1                                                                           
├─ path-to-regexp@0.1.7                                                                             
├─ performance-now@0.2.0                                                                            
├─ pify@3.0.0                                                                                       
├─ pinkie-promise@2.0.1                                                                             
├─ pinkie@2.0.4                                                                                     
├─ process-nextick-args@1.0.7                                                                       
├─ progress@2.0.0                                                                                   
├─ promise-props@1.0.0                                                                              
├─ promise@7.3.1                                                                                    
├─ prop-types@15.5.10                                                                               
├─ proxy-addr@1.1.5                                                                                 
├─ pseudomap@1.0.2                                                                                  
├─ punycode@1.3.2                                                                                   
├─ qrcode-terminal@0.11.0                                                                           
├─ qs@6.4.0                                                                                         
├─ querystring@0.2.0                                                                                
├─ range-parser@1.2.0                                                                               
├─ raw-body@2.2.0                                                                                   
├─ react-native-scripts@1.1.0                                                                       
├─ react-redux@5.0.5                                                                                
├─ read-chunk@2.1.0                                                                                 
├─ readable-stream@2.3.3                                                                            
├─ redux-logger@2.10.2                                                                              
├─ redux@3.7.2                                                                                      
├─ regenerator-runtime@0.10.5                                                                       
├─ remove-trailing-slash@0.1.0                                                                      
├─ request-progress@3.0.0                                                                           
├─ request@2.81.0                                                                                   
├─ reqwest@2.0.5                                                                                    
├─ rest-facade@1.5.0                                                                                
├─ restore-cursor@2.0.0                                                                             
├─ rimraf@2.6.1                                                                                     
├─ run-async@2.3.0                                                                                  
├─ rx-lite-aggregates@4.0.8                                                                         
├─ rx-lite@4.0.8                                                                                    
├─ safe-buffer@5.1.1                                                                                
├─ safe-json-stringify@1.0.4                                                                        
├─ semver@5.4.1                                                                                     
├─ send@0.15.3                                                                                      
├─ sentence-case@1.1.3                                                                              
├─ serve-static@1.12.3                                                                              
├─ setimmediate@1.0.5                                                                               
├─ setprototypeof@1.0.3                                                                             
├─ shebang-command@1.2.0                                                                            
├─ shebang-regex@1.0.0                                                                              
├─ signal-exit@3.0.2                                                                                
├─ slugid@1.1.0                                                                                     
├─ slugify@1.1.0                                                                                    
├─ snake-case@1.1.2                                                                                 
├─ sntp@1.0.9                                                                                       
├─ source-map-support@0.4.15                                                                        
├─ source-map@0.5.6                                                                                 
├─ sshpk@1.13.1                                                                                     
├─ statuses@1.3.1                                                                                   
├─ string_decoder@1.0.3                                                                             
├─ string-width@2.1.1                                                                               
├─ stringstream@0.0.5                                                                               
├─ strip-ansi@4.0.0                                                                                 
├─ superagent-retry@0.6.0                                                                           
├─ superagent@3.5.2                                                                                 
├─ supports-color@4.2.1                                                                             
├─ swap-case@1.1.2                                                                                  
├─ symbol-observable@1.0.4                                                                          
├─ tar.gz@1.0.5                                                                                     
├─ tar@2.2.1                                                                                        
├─ thenify-all@1.6.0                                                                                
├─ thenify@3.3.0                                                                                    
├─ throttleit@1.0.0                                                                                 
├─ through@2.3.8                                                                                    
├─ title-case@1.1.2                                                                                 
├─ tmp@0.0.31                                                                                       
├─ topo@2.0.2                                                                                       
├─ tough-cookie@2.3.2                                                                               
├─ tree-kill@1.1.0                                                                                  
├─ trim@0.0.1                                                                                       
├─ tunnel-agent@0.6.0                                                                               
├─ tweetnacl@0.14.5                                                                                 
├─ type-is@1.6.15                                                                                   
├─ ua-parser-js@0.7.14                                                                              
├─ universalify@0.1.1                                                                               
├─ unpipe@1.0.0                                                                                     
├─ upper-case-first@1.1.2                                                                           
├─ upper-case@1.1.3                                                                                 
├─ url@0.11.0                                                                                       
├─ util-deprecate@1.0.2                                                                             
├─ utils-merge@1.0.0                                                                                
├─ uuid@3.1.0                                                                                       
├─ vary@1.1.1                                                                                       
├─ verror@1.3.6                                                                                     
├─ whatwg-fetch@2.0.3                                                                               
├─ which@1.3.0                                                                                      
├─ winchan@0.1.4                                                                                    
├─ workspace-aggregator-d5775bd2-6a4e-47ad-8069-d4b04fbcc2f1@0.0.0                                  
├─ wrappy@1.0.2                                                                                     
├─ xdl@43.0.0                                                                                       
├─ xhr2@0.1.4                                                                                       
├─ xtend@4.0.1                                                                                      
├─ yallist@2.1.2                                                                                    
└─ yesno@0.0.1                                                                                      
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:
native@0.1.0 C:\robdonn\Personal\robdonn\test\apps\native
`-- (empty)
  • npm ls react-native:
native@0.1.0 C:\robdonn\Personal\robdonn\test\apps\native
`-- (empty)
  • npm ls expo:
native@0.1.0 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