cli icon indicating copy to clipboard operation
cli copied to clipboard

react native template error. [npx react-native init app]

Open ANANT-0000 opened this issue 1 year ago • 23 comments

C:\Users\manis\OneDrive\Documents\React Native>npx react-native init app

Running: npx @react-native-community/cli init

              Welcome to React Native!
             Learn once, write anywhere

warn The directory app contains files that will be overwritten: .git

√ Do you want to replace existing files? ... yes ⠹ Downloading templateerror Installing pods failed. This doesn't affect project initialization and you can safely proceed. However, you will need to install pods manually when running iOS, follow additional steps in "Run instructions for iOS" section.

✖ Downloading template

Run instructions for Android: • Have an Android emulator running (quickest way to get started), or a device connected. • cd "C:\Users\manis\OneDrive\Documents\React Native\app" && npx react-native run-android

ANANT-0000 avatar Aug 02 '24 15:08 ANANT-0000

Is it not running? Try removing the project from OneDrive folder.

alexandrersantana avatar Aug 03 '24 13:08 alexandrersantana

Hit the same issue, try initialising from an earlier version of react-native.

npx [email protected] init MyApp --skip-install

RobertFOConnor avatar Aug 12 '24 11:08 RobertFOConnor

Hi! Did you manage to create a new project from template with a newest RN version?

RNEvok avatar Aug 14 '24 20:08 RNEvok

Same error here

nikandlv avatar Aug 14 '24 21:08 nikandlv

Same error here

I feel like it is related to yarn v4. CLI says that node-modules of template are installed, but I dont see them actually appear on my disk. But the problem is I cant create .yarnrc.yml with nodeLinker: node-modules setting because CLI init command rewrites whole folder... (I am not sure for now)

RNEvok avatar Aug 14 '24 21:08 RNEvok

Nope, same happens with npm

On Thu, 15 Aug 2024, 00:48 Aleksandr, @.***> wrote:

Same error here

I feel like it is related to yarn v4. CLI says that node-modules of template are installed, but I dont see them actually appear on my disk. But the problem is I cant create .yarnrc.yml with nodeLinker: node-modules setting because CLI init command rewrites whole folder... (I am not sure for now)

— Reply to this email directly, view it on GitHub https://github.com/react-native-community/cli/issues/2468#issuecomment-2289922474, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADR7LW37XPY5A5GCO3XCZUTZRPCSTAVCNFSM6AAAAABL4YEH4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBZHEZDENBXGQ . You are receiving this because you commented.Message ID: @.***>

nikandlv avatar Aug 14 '24 21:08 nikandlv

Same error here

Me too

thalesaguiar avatar Aug 14 '24 21:08 thalesaguiar

Solution that I've found:

  1. Create project from template this way: npx react-native@latest init myawesomeproject --version 0.74.5 --pm npm --install-pods false

  2. When project is created, install pods the way you usually do it, for example: cd ios && arch -x86_64 pod install for mac with m1 CPU

P.S. I guess --install-pods false is the point there, but feel free to explore deeper

RNEvok avatar Aug 14 '24 21:08 RNEvok

@thalesaguiar @nikandlv Im gonna tag you so you wont waste any more time

RNEvok avatar Aug 14 '24 21:08 RNEvok

I was having the same issue on macos with @react-native-community/cli and was able to get past the template error by setting specific versions (also using yarn vs npm):

npx @react-native-community/[email protected] init AwesomeProject --version 0.74 --pm yarn

stevepartridge avatar Aug 14 '24 22:08 stevepartridge

Nice!! Now it works, thanks :)

@thalesaguiar @nikandlv Im gonna tag you so you wont waste any more time

thalesaguiar avatar Aug 15 '24 00:08 thalesaguiar

Same issue

boiboif avatar Aug 15 '24 09:08 boiboif

the @RNEvok solution works for me, thanks

ghost avatar Aug 15 '24 13:08 ghost

Now the standard command works: npx @react-native-community/cli@latest init AwesomeProject. But why doesn't it work afterward? Could it be an npm issue? :thinking:

thalesaguiar avatar Aug 15 '24 14:08 thalesaguiar

Solution that I've found:

  1. Create project from template this way: npx react-native@latest init myawesomeproject --version 0.74.5 --pm npm --install-pods false
  2. When project is created, install pods the way you usually do it, for example: cd ios && arch -x86_64 pod install for mac with m1 CPU

P.S. I guess --install-pods false is the point there, but feel free to explore deeper

this worked for me after using --install-pods false as suggested by @RNEvok Thanks :100

eldh0se avatar Aug 15 '24 17:08 eldh0se

The trick seems to be --pm npm

chrischjh avatar Aug 18 '24 09:08 chrischjh

i get similar error on mac when trying to initialize new RN 0.75.2 project.

npx @react-native-community/cli@latest init App

✖ Downloading template
error Installing pods failed. This doesn't affect project initialization and you can safely proceed.
However, you will need to install pods manually when running iOS, follow additional steps in "Run instructions for iOS" section.

when i use --pm yarn the command runs successfully.

full output
npx @react-native-community/cli@latest init App

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


              Welcome to React Native 0.75.2!
                 Learn once, write anywhere

✖ Downloading template
error Installing pods failed. This doesn't affect project initialization and you can safely proceed.
However, you will need to install pods manually when running iOS, follow additional steps in "Run instructions for iOS" section.

info 💡 To enable automatic CocoaPods installation when building for iOS you can create react-native.config.js with automaticPodsInstallation field.
For more details, see https://github.com/react-native-community/cli/blob/main/docs/projects.md#projectiosautomaticpodsinstallation



  Run instructions for Android:
    • Have an Android emulator running (quickest way to get started), or a device connected.
    • cd "/path/to/app/App" && npx react-native run-android

  Run instructions for iOS:
    • cd "/path/to/app/App/ios"

    • Install Cocoapods
      • bundle install # you need to run this only once in your project.
      • bundle exec pod install
      • cd ..

    • npx react-native run-ios
    - or -
    • Open App/ios/App.xcodeproj in Xcode or run "xed -b ios"
    • Hit the Run button

  Run instructions for macOS:
    • See https://aka.ms/ReactNativeGuideMacOS for the latest up-to-date instructions.

jozan avatar Aug 20 '24 14:08 jozan

Facing the same issue but finally i got a solution:- I was facing problem in my rbenv version first i make it global 3.1.2 and then also make changes in my zshrc file Then i use npx react-native init YourAppName --version 0.73.0 --template react-native-template-typescript Using this my app with tempalte was build successfully. **Please note that i have downgraded the version. **

Saifijaved47 avatar Aug 24 '24 00:08 Saifijaved47

Solution that I've found:

  1. Create project from template this way: npx react-native@latest init myawesomeproject --version 0.74.5 --pm npm --install-pods false
  2. When project is created, install pods the way you usually do it, for example: cd ios && arch -x86_64 pod install for mac with m1 CPU

P.S. I guess --install-pods false is the point there, but feel free to explore deeper

thank you so much..

NazimMertBilgi avatar Oct 01 '24 08:10 NazimMertBilgi

npx @react-native-community/cli@latest init AwesomeProject

this worked for me, i have npm and yarn both installed

Jamal-Ud-Din-hub avatar Jan 01 '25 09:01 Jamal-Ud-Din-hub

遇到同样的问题,尝试从早期版本的 react-native 初始化。

npx [email protected] init MyApp --skip-install

thanks! Your method helped me solve the problem

XiaoPangCao avatar Jan 09 '25 08:01 XiaoPangCao

npx @react-native-community/cli@latest init AwesomeProject

this worked for me, i have npm and yarn both installed

This worked for me as well, Thanks @Jamal-Ud-Din-hub

navinkris avatar Feb 04 '25 11:02 navinkris

I tried this method and managed to install

npx @react-native-community/cli init AwesomeProject --version 0.78.1

zohayk avatar Mar 31 '25 17:03 zohayk

There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

github-actions[bot] avatar Jun 30 '25 03:06 github-actions[bot]