39

I am using angular-cli to scaffold a new Angular2 project with ng new project_name. It takes a long time to complete, as it downloads all dependencies each time ng new is run. Is there a way to create subsequent new projects without having to re-download all the dependencies?

Fiddles
  • 2,790
  • 1
  • 32
  • 35
stackinfostack
  • 650
  • 2
  • 7
  • 12

6 Answers6

35

You can use ng new project_name --skip-install or ng init project_name --skip-install to not download all the additional packages right away. You could then copy the node_modules directory from an existing project template, and finally do an npm install or yarn install to make sure everything is happy, depending on your package manager.

Previous versions use ng new project_name --skip-npm or ng init project_name --skip-npm

Fiddles
  • 2,790
  • 1
  • 32
  • 35
  • Hi Filldes , Thanks for your reply...... I am facing one problems here 1) After running new new project_name --skip-npm.... Which working fine but after copying the node_modules and running npm install.... Again it is taking time .... What actually i want after creating project, Project should directly run by ng serve command.. – stackinfostack Oct 27 '16 at 01:28
  • 1
    @stackinfostack if you're confident that all the libraries are there and up-to-date, you should be able to skip the `npm install` and just run `ng serve`. – Fiddles Nov 03 '16 at 03:02
  • Got this message: The option '--skip-npm' is not registered with the new command. Run `ng new --help` for a list of supported options. – Julia Jan 13 '18 at 15:57
  • @Julia the command option might've changed in recent release. I'll check – Fiddles Jan 13 '18 at 16:21
  • 1
    Just run **ng new myproject** with the latest version of @angular/cli. The result is: "added 1457 projects in 287.624 seconds".. This is just insane.. And it does not seem to cache anything but does this 287 seconds insanity for every new project! Just compare this with creating a new project with Maven.. – John Donn Feb 08 '18 at 17:40
22

It is by far faster to use:

ng new myProject --skip-install=true
cd myProject
npm install
Kodjo Tchioffo
  • 421
  • 6
  • 6
6

If you are using latest angular-cli tool then use the following command.

$ ng new <project name> --skip-install=true

This will avoid npm to install all the required dependencies.

Krish.Venkat
  • 61
  • 1
  • 3
  • 1
    but to run the project you need dependencies so at the end you have to install them and its gonna take same time as there whole lot of them – Vikas Kandari Feb 25 '20 at 05:54
3

Run following two commands - ng new project_name --skip-npm //Only create project structure.
npm install //To install all necessary packages.

panku
  • 51
  • 8
0

Create new project ng new example

Wait a few seconds and cancel the installation of packages using ctrl+c then cd example

Now run npm install

Swaroop Maddu
  • 4,289
  • 2
  • 26
  • 38
-2

Create a new angular project ng new my-dream-application and press enter. When it is getting stuck, press the enter button twice or thrice then it completes smoothly.

Jagan
  • 1