Appending CRA gitignore to existing .gitignore fails due to fs-extra v8
Created by: mjsarfatti
Describe the bug
Creating a new app in a folder with an existing .gitignore fails with error Error: dest already exists.
. This is using the master branch (I discovered it while forking it to customize CRA), but it will happen on tagged releases as well.
The reason is react-scripts/scripts/init.js:175
checks for:
if (err.code === 'EEXIST') {
in order to decide whether to append CRA's gitignore to the existing file. But fs-extra/moveSync v8
instead of throwing an error with code EEXIST
seems to be throwing an error with message dest already exists.
and undefined code.
Did you try recovering your dependencies?
Not applicable.
Which terms did you search for in User Guide?
"EEXIST", "dest already exists", "gitignore".
Environment
Environment Info:
System:
OS: macOS 10.15
CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Binaries:
Node: 10.14.2 - /usr/local/bin/node
Yarn: 1.16.0 - ~/.yarn/bin/yarn
npm: 6.10.3 - ~/npm/bin/npm
Browsers:
Chrome: 77.0.3865.120
Firefox: 70.0
Safari: 13.0.2
npmPackages:
react: Not Found
react-dom: Not Found
react-scripts: Not Found
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
- Create a folder and a sample .gitignore file
-
cd
into the folder and runnpx create-react-app .
Expected behavior
App is initialized and CRA gitignore is appended to existing .gitignore
Actual behavior
Installation fails. Here is the last lines of the console log:
...
├─ terser-webpack-plugin@2.2.1
├─ terser@4.3.9
├─ url-loader@2.2.0
├─ webpack-manifest-plugin@2.2.0
└─ webpack@4.41.2
✨ Done in 20.68s.
/Users/manus/Lavori/Web/AGENCY-APPS/2019/2019n13_Bip_SimPLE/simple-app/node_modules/react-scripts-laravel/scripts/init.js:182
throw err;
^
Error: dest already exists.
at doRename (/Users/manus/Lavori/Web/AGENCY-APPS/2019/2019n13_Bip_SimPLE/simple-app/node_modules/fs-extra/lib/move-sync/move-sync.js:25:34)
at Object.moveSync (/Users/manus/Lavori/Web/AGENCY-APPS/2019/2019n13_Bip_SimPLE/simple-app/node_modules/fs-extra/lib/move-sync/move-sync.js:17:10)
at module.exports (/Users/manus/Lavori/Web/AGENCY-APPS/2019/2019n13_Bip_SimPLE/simple-app/node_modules/react-scripts-laravel/scripts/init.js:168:8)
at [eval]:3:14
at Script.runInThisContext (vm.js:96:20)
at Object.runInThisContext (vm.js:303:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at evalScript (internal/bootstrap/node.js:586:27)
at startup (internal/bootstrap/node.js:264:9)
Aborting installation.
node has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting generated file... yarn.lock
Done.
Reproducible demo
Not applicable.