ueno-llc / react-native-starter

Professional react-native starter kit with everything you'll ever need to deploy rock solid apps
https://ueno-llc.github.io/react-native-starter
MIT License
574 stars 90 forks source link

'-f was unexpected at this time' on prepare script (yarn postinstall) #222

Closed dylmye closed 5 years ago

dylmye commented 5 years ago

Describe the bug When installing react-native-starter as described below on Windows 10, the following error is outputted:

Error: Command failed: npm run prepare
-f was unexpected at this time.
npm ERR! errno 1
npm ERR! react-native-starter@2.1.0 prepare: `patch-package && if [ -f ./scripts/postinstall.sh ]; then sh ./scripts/postinstall.sh; fi`

To Reproduce Steps to reproduce the behavior:

  1. From fresh: clone, cd to app
  2. yarn

Expected behavior App's dependencies install as expected with no errors

Debug log

λ yarn
yarn install v1.9.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.4: The platform "win32" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > @react-native-community/async-storage@1.2.0" has incorrect peer dependency "react-native@^0.57.0".
warning " > mobx-devtools-mst@0.9.18" has incorrect peer dependency "mobx@^2.2.0 || ^3.0.0".
warning " > react-native@0.59.0-rc.3" has incorrect peer dependency "react@16.8.3".
warning "react-native > @react-native-community/cli@1.3.2" has incorrect peer dependency "react-native@^0.57.0".
warning "react-native > metro-react-native-babel-transformer > babel-preset-fbjs > @babel/plugin-check-constants@7.0.0-beta.38" has incorrect peer dependency "@babel/core@7.0.0-beta.38".
[4/4] Building fresh packages...
[6/9] ⠈ electron
[7/9] ⠈ node-sass
[-/9] ⠈ waiting...
[4/9] ⠈ dtrace-provider
error X:\path\to\app\node_modules\postinstall-prepare: Command failed.
Exit code: 1
Command: node ./run.js
Arguments:
Directory: X:\path\to\app\node_modules\postinstall-prepare
Output:
-f was unexpected at this time.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-native-starter@2.1.0 prepare: `patch-package && if [ -f ./scripts/postinstall.sh ]; then sh ./scripts/postinstall.sh; fi`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-native-starter@2.1.0 prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     Z:\path\to\user\AppData\Roaming\npm-cache\_logs\2019-06-14T23_20_20_987Z-debug.log
child_process.js:645
    throw err;
    ^

Error: Command failed: npm run prepare
-f was unexpected at this time.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-native-starter@2.1.0 prepare: `patch-package && if [ -f ./scripts/postinstall.sh ]; then sh ./scripts/postinstall.sh; fi`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-native-starter@2.1.0 prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     Z:\path\to\user\AppData\Roaming\npm-cache\_logs\2019-06-14T23_20_20_987Z-debug.log

    at checkExecSyncError (child_process.js:602:13)
    at execSync (child_process.js:642:13)
    at Object.<anonymous> (X:\path\to\app\node_modules\postinstall-prepare\run.js:14:5)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)

Environment

This is a fresh install so versions don't really matter

Additional context

λ react-native info
info
  React Native Environment Info:
    System:
      OS: Windows 10
      CPU: x64 AMD Ryzen 5 1600 Six-Core Processor
      Memory: 5.34 GB / 15.95 GB
    Binaries:
      Yarn: 1.9.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD

λ react-native -v
react-native-cli: 2.0.1
react-native: 0.59.0-rc.3
dylmye commented 5 years ago

I'm not sure if this is an actual issue with the project or my machine. Happy to help debug this if possible. :) Thank you!

dylmye commented 5 years ago

going further into using this project it seems like it's only been tested on MacOS. Having issues with the build.gradle and yarn rename too. Would be useful noting this in the readme if this is the case :/

jeremybarbet commented 5 years ago

Hi!

Yeah you are right, we didn't test it on Windows system, only on MacOS.

Even though, the issue happens during the yarn installation and seems related to patch-package dependency.

I pushed a commit with upgraded dependencies on the package.json, if you can try again and let me know if the issue is still there or not, it would be nice!

dylmye commented 5 years ago

Thanks @jeremybarbet, I'll try to let you know within 24 hrs :)

dylmye commented 5 years ago

Thanks again for having a look into it. Got further today, unfortunately still couldn't build following instructions.

yarn rename "UenoTest" com.dylmye.uenotest output:

yarn run v1.9.4                                                                                                
$ sh ./scripts/rename.sh UenoTest com.dylmye.uenotest                                                          
Switched to a new branch 'feature/rename'                                                                      

> Renaming the application                                                                                     

  Id: com.dylmye.uenotest                                                                                      
  Name: UenoTest                                                                                               
  Slug: uenotest                                                                                               

The system cannot find the path specified.                                                                     
The system cannot find the path specified.                                                                     
The system cannot find the path specified.                                                                     
The system cannot find the path specified.                                                                     
The system cannot find the path specified.                                                                     
The system cannot find the path specified.                                                                     
The system cannot find the path specified.                                                                     
The system cannot find the path specified.                                                                     
The system cannot find the path specified.                                                                     
The system cannot find the path specified.                                                                     
The system cannot find the path specified.                                                                     
> Patching android/app/src/main/AndroidManifest.xml                                                            
> Patching android/app/src/androidTest/java/com/dylmye/uenotest/DetoxTest.java                                 
> Patching android/app/proguard-rules.pro                                                                      
> Patching ios/fastlane/Fastfile                                                                               
> Patching ios/*/Info.plist                                                                                    
> Patching ios/*.xcodeproj/project.pbxproj                                                                     
> Patching ios/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme                                                   
> Patching scripts/build-env.sh                                                                                
> Patching appcenter-pre-build.sh                                                                              
> Patching package.json                                                                                        
[Ueno RNS] Config building...                                                                                  
[Ueno RNS] Warning: No GoogleService-Info.plist file in ios app directory... We created a placeholder for you! 
./scripts/build-env.sh: line 44: ./ios/UenoTest/GoogleService-Info.plist: No such file or directory            
[Ueno RNS] Building environment config                                                                         
[Ueno RNS] Using .env                                                                                          
[Ueno RNS] Generating ./src/config.env.js                                                                      
[Ueno RNS] Config built successfully!                                                                          

[...some git stuff...]

error: unable to create file scripts/rename.sh: Permission denied              
Switched to branch 'master'                                                    
>       scripts/rename.sh                                                      
Your branch is up to date with 'origin/master'.                                
error: Your local changes to the following files would be overwritten by merge:
        scripts/rename.sh                                                      
Please commit your changes or stash them before you merge.                     
Aborting                                                                       
Updating 70f648a..06660ad                                                      
Deleted branch feature/rename (was 06660ad).                                   

> Successfully renamed app                                                     
Initialized empty Git repository in X:\path\to\app\uenorns\.git\            
error: open("scripts/rename.sh"): Permission denied                            
error: unable to index file scripts/rename.sh                                  
fatal: adding files failed 

[...more git stuff...]

nothing added to commit but untracked files present
error Command failed with exit code 1.                                                    

react-native run-android output:

info Starting JS server...
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...
Downloading https://services.gradle.org/distributions/gradle-4.10.2-all.zip
[...gradle downloads and unzips...]
Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :

[...no errors here, just modules and their folders...]

> Configure project :@react-native-community_async-storage
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.

Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.                   

FAILURE: Build failed with an exception.                                                                                                             

* What went wrong:                                                                                                                                   
A problem occurred evaluating project ':app'.                                                                                                        
> A problem occurred starting process 'command './scripts/build-env.sh''                                                                             

* Try:                                                                                                                                               
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. 

* Get more help at https://help.gradle.org                                                                                                           

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.                                                          
Use '--warning-mode all' to show the individual deprecation warnings.                                                                                
See https://docs.gradle.org/4.10.2/userguide/command_line_interface.html#sec:command_line_warnings                                                   

BUILD FAILED in 3m 21s                                                                                                                               
error Could not install the app on the device, read the error above for details.                                                                     
Make sure you have an Android emulator running or a device connected and have                                                                        
set up your Android development environment:                                                                                                         
https://facebook.github.io/react-native/docs/getting-started.html                                                                                    
error Command failed: gradlew.bat app:installDebug                                                                                                   

Hope this helps. Please let me know if there's anything else I can do to assist.

jeremybarbet commented 5 years ago

Hi!

I tried on a windows machine, and it's more broken than expected. The whole rename script is not successfully executed and a lot of files are not renamed because not found.

I pushed some fixes, but it's not complete. I'll look at it when I'll have more time

birkir commented 5 years ago

This has been removed from the package.json file now