Home > Net >  An error occurred while setting up a new react-native project
An error occurred while setting up a new react-native project

Time:12-10

I'm a newbie in React-native. I am trying to setup a react-native project without expo and using Typescript but something goes wrong and I don't understand what is causing the error.

Here is my terminal content when I run command: npx react-native init MyApp --template react-native-template-typescript

               ######                ######               
             ###     ####        ####     ###             
            ##          ###    ###          ##            
            ##             ####             ##            
            ##             ####             ##            
            ##           ##    ##           ##            
            ##         ###      ###         ##            
             ##  ########################  ##             
          ######    ###            ###    ######          
      ###     ##    ##              ##    ##     ###      
   ###         ## ###      ####      ### ##         ###   
  ##           ####      ########      ####           ##  
 ##             ###     ##########     ###             ## 
  ##           ####      ########      ####           ##  
   ###         ## ###      ####      ### ##         ###   
      ###     ##    ##              ##    ##     ###      
          ######    ###            ###    ######          
             ##  ########################  ##             
            ##         ###      ###         ##            
            ##           ##    ##           ##            
            ##             ####             ##            
            ##             ####             ##            
            ##          ###    ###          ##            
             ###     ####        ####     ###             
               ######                ######               
                                                          

                  Welcome to React Native!                
                 Learn once, write anywhere               

✔ Downloading template
✔ Copying template
✔ Processing template
✖ Installing Bundler
error /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin22/rbconfig.rb:21: warning: Insecure world writable dir /usr/local/mongodb in PATH, mode 040777

✖ Installing Bundler
error Error: Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/next/environment-setup and follow the React Native CLI QuickStart guide for macOS and iOS.
Error: Error: Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/next/environment-setup and follow the React Native CLI QuickStart guide for macOS and iOS.
    at createFromTemplate (/Users/phamthanhphuc/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/commands/init/init.js:169:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.initialize [as func] (/Users/phamthanhphuc/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/commands/init/init.js:222:3)
    at async Command.handleAction (/Users/phamthanhphuc/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/index.js:140:9)
info Run CLI with --verbose flag for more details.

Please help me! Thank you for your help!

CodePudding user response:

You will need to have root access to do this. If you aren't already the administrative user, login as the administrator. Then use 'sudo' to change the permissions:

sudo chmod go-w /usr/local/bin

Obviously, that will mean you can no longer install material in /usr/local/bin except via 'sudo', but you probably shouldn't be doing that anyway.

Or

You need to set ios environment path Please prefer this link : https://reactnative.dev/docs/environment-setup

  • Related