0

earlier I have installed create-react-app globally, and I have used npx create-react-app appName command for several times to create new react application. Everything was working fine, but all of sudden I am facing issue in creating new app using the same command.

Existing react apps are working fine, I can navigate to those directories and run npm start, and application will start running/working smoothly, which concludes only create-react-app is not working properly.

NPM version : 6.14.11

Node version : v10.15.3

React script version (found in package.json of existing app):

"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.0",

I have gone through this stack-overflow question and tried few suggestions given in answers

I tried cleaing the cache: npm cache clean --force

I updated npm version npm install npm@latest -g

I have tried using these 3 ways :

  1. npx create-react-app test100

  2. creating directory test100 first, then from that directory npx create-react-app .

  3. As here its mentioned that if create-react-app is globally installed then no need to use npm/npx/yarn. So tried this one create-react-app test100

But whatever I try, I get same error as follows, which says its having trouble copying some favicon file from CRA template, to public directory of application, then it terminates whole operation and deletes package.json file.

Please let me know how can I resolve this issue, as I am stuck in it from long time, any help will be appreciated.

Note: I'm working on windows machine, and have opened VScode in administrator mode.

Please go through following error, which I'm getting in VScode powershell console:

PS C:\Vikrant Local\react> npx create-react-app test100

Creating a new React app in C:\Vikrant Local\react\test100.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...


> core-js@2.6.12 postinstall C:\Vikrant Local\react\test100\node_modules\babel-runtime\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"


> core-js@3.8.3 postinstall C:\Vikrant Local\react\test100\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"


> core-js-pure@3.8.3 postinstall C:\Vikrant Local\react\test100\node_modules\core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"


> ejs@2.7.4 postinstall C:\Vikrant Local\react\test100\node_modules\ejs
> node ./postinstall.js

+ cra-template@1.1.1
+ react@17.0.1
+ react-scripts@4.0.1
+ react-dom@17.0.1
added 1903 packages from 722 contributors and audited 1906 packages in 95.612s

126 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

fs.js:114
    throw err;
    ^

Error: UNKNOWN: unknown error, copyfile 'C:\Vikrant Local\react\test100\node_modules\cra-template\template\public\favicon.ico' 
-> 'C:\Vikrant Local\react\test100\public\favicon.ico'
    at Object.copyFileSync (fs.js:1723:3)
    at copyFile (C:\Vikrant Local\react\test100\node_modules\fs-extra\lib\copy-sync\copy-sync.js:67:6)
    at onFile (C:\Vikrant Local\react\test100\node_modules\fs-extra\lib\copy-sync\copy-sync.js:53:25)
    at getStats (C:\Vikrant Local\react\test100\node_modules\fs-extra\lib\copy-sync\copy-sync.js:48:44)
    at startCopy (C:\Vikrant Local\react\test100\node_modules\fs-extra\lib\copy-sync\copy-sync.js:38:10)
    at copyDirItem (C:\Vikrant Local\react\test100\node_modules\fs-extra\lib\copy-sync\copy-sync.js:122:10)
    at fs.readdirSync.forEach.item (C:\Vikrant Local\react\test100\node_modules\fs-extra\lib\copy-sync\copy-sync.js:115:39)    
    at Array.forEach (<anonymous>)
    at copyDir (C:\Vikrant Local\react\test100\node_modules\fs-extra\lib\copy-sync\copy-sync.js:115:23)
    at mkDirAndCopy (C:\Vikrant Local\react\test100\node_modules\fs-extra\lib\copy-sync\copy-sync.js:110:3)

Aborting installation.
  node  has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Done.

1 Answers1

0

how about using yarn to create your CRA template.

run npm i -g yarn

and then yarn create react-app my-app

Kaur Kaelep
  • 111
  • 1
  • 3
  • Thanks for your reply. I don't find any issue with NPM, as few days ago I was able to use npx create-react-app command, and even now I am able to run my previous react apps using npm start. So I don't know whether switching to yarn could be the most accurate solution. – Vik Durve Jan 22 '21 at 13:08