If you only have the zip file to install angular-cli with - how can it be installed without an internet connection?
-
1Do you have a ZIP file ? – Koby Douek Mar 16 '17 at 18:02
-
I sure do, downloaded from github – Jay Ordway Mar 16 '17 at 18:02
-
And when you extract it, what files do you see ? – Koby Douek Mar 16 '17 at 18:03
-
bin, lib, docs, plugins, scripts, test, package.json, README, tsconfig.... all of what you would expect – Jay Ordway Mar 16 '17 at 18:04
-
1You'll probably first have to install it on a computer that DOES have internet because you'll need all it's dependencies which I would not expect to be in that zip file. – Corey Ogburn Mar 16 '17 at 18:04
-
@CoreyOgburn I believe you are correct about that - any other details? Clearly, if you try to install the zip file, it will try to pull all of its dependencies down via the net but won't make a connection. – Jay Ordway Mar 16 '17 at 18:06
-
Do you have npm ? – Koby Douek Mar 16 '17 at 18:07
-
Yes node and npm were installed. – Jay Ordway Mar 16 '17 at 18:07
-
I saw this: https://addyosmani.com/blog/using-npm-offline/ but was hoping for something more straightforward. – Jay Ordway Mar 16 '17 at 18:07
-
1The first place I'd start would be (on a computer with internet) running `npm install angular-cli@latest` in a clean empty folder and then I'd zip up the resulting node_modules folder. You may still run into problems, but you'll have your dependencies. – Corey Ogburn Mar 16 '17 at 18:07
-
Can you connect this computer to the internet for a couple of minutes? – Koby Douek Mar 16 '17 at 18:10
-
@KobyDouek No, that is not an option – Jay Ordway Mar 16 '17 at 18:12
-
Just try running npm like the instructions here, but I'm really skeptic about this - from what I know it needs downloading some dependencies. Try it and hope for the best: https://github.com/neoziro/angular-offline – Koby Douek Mar 16 '17 at 18:13
-
@Claies I'd have to disagree. You can build websites completely offline, and use all of Angular capabilities. – Koby Douek Mar 16 '17 at 18:24
-
@Claies It is a matter of security on the development box. Software and open source can only be brought onto the box through certain means, not directly installed from internet. – Jay Ordway Mar 16 '17 at 18:24
3 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
oryarn
- 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.

- 431
- 4
- 12

- 22,502
- 10
- 80
- 121
-
1Did you try this? Some repos (notably Angular ones) doesn't contain pre-built files in their repos. This means that there are no JS files in Github archive, only TS. – Estus Flask Dec 14 '17 at 21:31
-
So what's the problem? Cli can compile TypeScript projects without any trouble. I don't follow. Try it and you'll see :) – maxime1992 Dec 15 '17 at 06:40
-
Resulting zipped package won't be workable. cli can't compile itself. Try your own answer and you'll see. – Estus Flask Dec 15 '17 at 06:51
-
1I think one potential issue to note with this is if there may be differences in the platforms between the mentioned offline and online computer, since the node-sass package requires the download of a binary that is platform dependent. If there is a way to circumvent this problem, I am unaware. I know the binary can be kept locally and installed via the local file instead of public repo if given the correct command line argument. – Jay Ordway Dec 15 '17 at 09:05
-
I agree this is a good solution, we ended up making a private npm repo behind the corporate proxy. – Jay Ordway Dec 15 '17 at 09:06
----online machine-----
- Install node by using the executable files downloaded from the official node website.
- Install the @angular/cli globally on the on-line machine.
- Check the C:\Users\Admin\AppData\Roaming folder.
- Zip the npm and npm_cache folder.
- Transfer the above zip file and node executable to the offline machine.
- Create the new project in angular
- zip the node_module folder inside the created project and transfer it to the offline machine.
----Offline Machine------
- Install node from its executable
- Unzip the npm and npm_cache folder and move it to the C:\Users\Admin\AppData\Roaming folder.
- Run the following command to install the @angular/cli and its dependencies
npm i @angular/cli -g --cache MY_CACHE_FOLDER --cache-min 999999999 --no-shrinkwrap
- Now create the new angular project. It will show some errors but don't worry.
- Unzip and move the node_module folder inside the new project.
- Now, you can work/run on the project as usual.

- 2,654
- 2
- 29
- 31

- 61
- 1
- 3
This would be a good solution for your case.
npm i @angular/cli -g --cache MY_CACHE_FOLDER --cache-min 999999999 --no-shrinkwrap
You can find full article here.