DEV Community

Stuart Muyambi
Stuart Muyambi

Posted on

CAN I DUPLICATE A FRESH REACT APP FOR ANOTHER APP?

Hello everyone, Just recently i started learning React. From a background of writing html, css and vanilla javascript, React can be overwhealming. The download process takes longer than i expected and includes a ton of files which can be pretty intimidating for a beginner.

I thought to myself, can i just duplicate a new react app i just created with create-react-app command and use it to do other projects? i tried it and it actually worked but are there any outcomes from doing so? Thank you

Top comments (10)

Collapse
 
codemochi profile image
Code Mochi

Yes you can definitely do this- you'll find that the node_modules folder is the largest piece of this. Just to be safe if the packages are similar, you can copy it and then do an npm install in the folder and you should fetch any packages that changed or you didn't have for whatever reason.

Collapse
 
stuartmuyambi profile image
Stuart Muyambi

Wouldn't it affect the perfomace of the new app?

Collapse
 
codemochi profile image
Code Mochi

No it shouldnโ€™t matter. Yarn is a competitor to npm and it will actually cache your packages which is essentially the same idea you are doing here. With that said, just because you can do this, if it gives you problems just do an npm install to make sure you package versions are all good.

Collapse
 
nachodev profile image
Fortune Iheanacho

Please can you explain how it can be done?

Collapse
 
vonheikemen profile image
Heiker

I can recommend that you check pnpm. It's a package manager that has an awesome cache system for packages. It only downloads a package version once and keep it in one place, then it creates a link from the cache folder to your project. Once your cache folder has the most common packages you use the install process is very fast.

Collapse
 
larsklopstra profile image
Lars Klopstra โšก

You could, but why would you?

Collapse
 
atulpatil99 profile image
Atul Patil

cause then we would not have to wait for create-react-app take ages to install. We can just copy that directory rename it and then we can use it for out next project right?

Collapse
 
stuartmuyambi profile image
Stuart Muyambi

On a slow internet connection the download takes abit longer than it should

Collapse
 
jameshubert_com profile image
James Hubert

Thank you for asking this. I've been wondering for a long time.

Collapse
 
nachodev profile image
Fortune Iheanacho

Please can you explain how you did it?