Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create new Angular application with CLI takes too much time

Tags:

angular

Whenever I run "ng new ProjectName" CLI command it takes couple of minutes to create the project.

Is there a faster way to create a project like copying an existing project and changing some parameters? As far as I understand ng new downloads lots of modules.

like image 391
Salim Avatar asked Jun 22 '17 14:06

Salim


2 Answers

You can keep an original/unmodified as a template:

ng new AngularCLITemplate

and when you build future projects you can skip installing node_modules:

ng new --skip-install true NewProjectName

then copy and paste your node_modules folder from the template into your new project. Afterward you'll want to npm install:

cd NewProjectName && npm install to make sure it caches the npm module locations.

It will be close to the same time to build a new project, since downloading the node_modules doesn't take as much time as simply writing them to the disk during installation (which the copy/paste will have to do), but it might save a minute or two on an older machine or slower internet.

like image 82
Z. Bagley Avatar answered Sep 27 '22 23:09

Z. Bagley


hi bro this is because angular cli installs the dependencies running

npm install 

but to make it faster you can use yarn.

If you haven't installed yet

npm install -g yarn

this use npm, other ways of installing in the following link.

https://yarnpkg.com/lang/en/docs/install/

ng new --skip-install true NewProjectName // will avoid npm install 

ng set --global packageManager=yarn

using yarn will decrease your speed at least by half, if you want to get back to npm.

ng set --global packageManager=npm
like image 36
Mauricio De La Quintana Avatar answered Sep 27 '22 21:09

Mauricio De La Quintana