Can i install React and create new apps without having to download it from npm?
during most of my day my internet is slow so when i try to make new React app it basically fails on me is there a way to save React globally on my pc or can i install one app and keep copy and past the empty app every time i try to make new one or what other solutions would you guys recommend?
6 Replies
Normally npm should cache a local copy after the first download. However it's possible it still needs to check for latest versions of packages. In any case, the answer is yes, just copy + paste the contents of
node_modules
wherever you need it an it'll work.
Not that this is the recommended way long-term, just to be clear. It'll definitely make things harder to manage the larger the project and the more dependencies you have so using npm for that is definitely the best way to go. But for now that should do it.you can definitely copy paste an existing project folder as a blueprint/template. Might be faster zipping it after you installed your basic packages and then unzip it in your new project folder.
yarn
and pnpm
have a more aggressive caching than npm
.
might be worth trying those.
they're also faster than npm
in setting up and installing projects.Will there be issues with the lock file?
If you copy the entire node_modules folder from another project to an already existing one? Most likely. Copying this from another project, even if it's identical, may already have different versions on some dependencies and sub-dependencies. I don't know for sure, but I also don't have the need to find that out, honestly. Just install packages normally, even if it takes some time it's a one time thing.
Assuming you're using
npx create-react-app
to create your apps, I'll suggest you to use Vite instead. Which will basically do the same, but will download much faster and will require much less files.
Here's command to create react app with vite:
It will then ask you for project name, and to select framework you'd like to use in your app (if you want to use any).
Here's a video of other tools you could also use for creating apps:
https://www.youtube.com/watch?v=kvkAoCbTM3Q&t=297sWeb Dev Simplified
YouTube
Stop Using Create React App
Create React App is an incredible tool that made it easy to setup and work with React, but as the years have gone by CRA has become less and less useful to the point that you should pretty much never use it. In this video I talk about all the alternatives to CRA that you should consider using instead.
š Materials/References:
Astro vs Gatsby V...
Vite
Next Generation Frontend Tooling