Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install angular-cli without internet

If you only have the zip file to install angular-cli with - how can it be installed without an internet connection?

like image 355
Jay Ordway Avatar asked Mar 16 '17 18:03

Jay Ordway


People also ask

Can Angular run without internet?

It never actually has to ask the internet for anything. The service worker has all the files you will need. Conversely, this also means that even if you do have internet, the application will also run faster.

Can I install Angular locally?

Angular CLI provides a complete tool-chain for developing front-end apps on your local machine. As such, you don't need to install a local server to serve your project — you can simply, use the ng serve command from your terminal to serve your project locally.

How do I run an Angular project offline?

This can be done by using the offline checkbox in the Network tab of Chrome dev tools (it has options to simulate slow network connections also). As you can see, it gives the 'No internet' screen ( the dinosaur game screen 🎮). Using service workers, we can change this behavior.

Can we run Angular without Angular CLI?

We can run the application in Visual Studio using F5 or Ctrl + F5 in Angular quick start application. Go to solution explore under src folder which has “index.


1 Answers

With that ZIP only you will not be able to achieve that.

Because within the bin folder, the ng still needs some dependencies.

In order to do that:

  • Download the zip from the official repo: https://github.com/angular/angular-cli/archive/master.zip
  • Unzip it and go into that folder
  • Run npm install or yarn
  • Zip the whole folder again

Now you'll be able to run the CLI on an offline computer if you share that zip by doing:
- Unzip the CLI folder with the node_modules in it
- /path/to/the/folder/bin/ng new my-project

BUT. As this computer is offline, you'll only be able to scaffold a new project without installing it's required dependencies.

Now, if you want to build a project on that offline computer, you'll need something more:

On the online computer:
- install @angular/cli yarn global add @angular/cli (or use your zip)
- create a new empty project while online: ng new base-project
(wait for yarn install or npm install to finish)
- zip the node_modules folder, the one within the new project
(as node_modules_backup.zip for ex, and brace yourself... It's going to take a long time I guess)

On the offline computer
- Share the ZIP from the new project (with USB for ex) - Create your project: /path/to/the/folder/bin/ng new my-project --skip-install
- Unzip the node_modules_backup.zip into the newly created project

Now running /path/to/the/folder/bin/ng serve should work.

like image 132
maxime1992 Avatar answered Sep 19 '22 09:09

maxime1992