Offline mode
Created by: gaearon
npm wizards, we need your help!
Per @pselle’s suggestion, we should try to find a way to make create-react-app
work offline.
I’m not well versed in npm flags and likely won’t have time for this, so this is a perfect opportunity for you to contribute and significantly improve the user experience of Create React App.
Here is the behavior we’re looking for:
- Existing requirement:
create-react-app my-app
should use the most recent version ofreact-scripts
if you are online. We are not changing this: we always want the users to get the most recent one. - New requirement:
create-react-app my-app
should not crash offline if you ran it at least once before. It should be able to use locally cachedreact-scripts
in this case, if it exists. - Bonus:
create-react-app my-app
should use cachedreact-scripts
if it knows the latest npm version is cached locally. In other words, even if you are online, we shouldn’t just refetch the whole thing if we have it locally and we know it is the latest version. This is not required but would make a big difference for most people. - Acceptable tradeoff: we are fine with not installing the latest transitive dependencies. In other words it’s fine if
react-scripts
depends onsome-package@1.0.0
, thensome-package@1.0.1
comes out, but we keep using the cachedsome-package@1.0.0
.
How to achieve this? I have no idea.
Maybe this would be helpful: https://addyosmani.com/blog/using-npm-offline/.
We already use bundledDependencies
(which is a bit unusual) as part of our build process so in reality react-scripts
is being downloaded as a single tarball rather than through the usual npm process. Perhaps this can give us the leverage to make this better (e.g. by caching that tarball somehow).