cli: `npx react-native init AwesomeProject` not working

➜ npx react-native init AwesomeProject2

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


                  Welcome to React Native!
                 Learn once, write anywhere

✔ Downloading template
✖ Copying template
error Error: Couldn't find the "/var/folders/w5/bsw5vt490q78cyx2_h42ldtw0000gn/T/rncli-init-template-nzsCCY/node_modules/react-native/template.config.js file inside "react-native" template. Please make sure the template is valid. Read more: https://github.com/react-native-community/cli/blob/master/docs/init.md#creating-custom-template

I’m on Mac OS and don’t have the react-native cli installed globally.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 40 (22 by maintainers)

Most upvoted comments

@chenweigh I was also receiving similar error as below when running npx react-native init MyAwesomeApp --template react-native-template-typescript:

npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /Users/sufian/.npm/_npx/7930a8670f922cdb/node_modules/babel-plugin-polyfill-regenerator
npm ERR! dest /Users/sufian/.npm/_npx/7930a8670f922cdb/node_modules/.babel-plugin-polyfill-regenerator-1PdlkCQk
npm ERR! errno -66
npm ERR! ENOTEMPTY: directory not empty, rename '/Users/sufian/.npm/_npx/7930a8670f922cdb/node_modules/babel-plugin-polyfill-regenerator' -> '/Users/sufian/.npm/_npx/7930a8670f922cdb/node_modules/.babel-plugin-polyfill-regenerator-1PdlkCQk'

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sufian/.npm/_logs/2022-10-04T14_18_11_578Z-debug-0.log

Replacing npx react-native with npx react-native@latest solved it for me.

Running sudo npx react-native init AwesomeProject2 made it work. The download too way longer than before, so I’m guessing that it could not stream the download into the destination correctly.

Obviously running as sudo has implications, but writing down my stream of thoughts as I debug this may be helpful to others.

chen@chen ~ % npx react-native init AwesomeProject

Need to install the following packages: react-native Ok to proceed? (y) y npm ERR! code ENOTEMPTY npm ERR! syscall rename npm ERR! path /Users/chen/.npm/_npx/7930a8670f922cdb/node_modules/react-native npm ERR! dest /Users/chen/.npm/_npx/7930a8670f922cdb/node_modules/.react-native-JAoXw5Fv npm ERR! errno -66 npm ERR! ENOTEMPTY: directory not empty, rename ‘/Users/chen/.npm/_npx/7930a8670f922cdb/node_modules/react-native’ -> ‘/Users/chen/.npm/_npx/7930a8670f922cdb/node_modules/.react-native-JAoXw5Fv’

npm ERR! A complete log of this run can be found in: npm ERR! /Users/chen/.npm/_logs/2022-01-26T10_18_02_465Z-debug.log


How to fix ?

In Windows 10 doesn’t work.

image

Steps that do work in the temporary folders is to run yarn init -y before running yarn add react-native

Cc @Esemesek. I think we could do init, just need to figure out something that works with yarn and npm 😃

The line that is failing is the step that creates the template. The step that creates the template runs: yarn add react-native@latest

Maybe it’s something with permissions? We’ve seen a few users having similar issues and reasons were varying. We can’t really reproduce it ourselves. If you could debug this (clone this repo and follow CONTRIBUTING.md instructions), we’d be thankful for your help