简体   繁体   中英

Bootstrapping offline a web application with npm

I know that it could sound weird asking for start developing offline an application (probably) web oriented, specially nowadays that we live on an allways connected world, but I'm seriously tired of this situation.

Every time I want to start a project using modern web technologies and tools (webpack, gulp, node, express, and so on...) I need an internet connection. No matter if I have installed gulp globally or If I have express installed on dozens of projects I allways have to type npm install and wait for the whole thing to download, once again. In any other language (seriously, any) you install the sdk, or the runtime, or whatever is required and you are ready to go, no more downloads are required. How can I achieve something similar in the npm world?

Before anyone asking why, there are dozens of reasons I want this:

  • Restrictive proxy
  • Developing while traveling
  • Poor internet connection
  • Mobile data plan

What alternatives do we have? Is it possible to setup some kind of offline repository, or cache or something like that?

Thanks in advance. ....

The best solution that I found so far is sinopia: https://github.com/rlidwka/sinopia/

It is a npm registry that you can run locally. It allows you to publish private packages to it (soo cool) but the best part is that it caches all your request to npm, so once you install a package it is saved inside sinopia and you will not download it again after that. It has some extra benefits like running your own private npm repo on your own server infrastructure, but that is another story.

Would installing globally (-g flag) help?

npm install -g [package]

If not, make a folder for your packages and keep copies of their .js files there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM