Solution: Angular `ng new` command stuck at ‘Installing packages for tooling via npm’

So I am learning Angular 2 and decided to use Angular CLI this time instead of those seed projects.

BTW, I am following this course to study basics of Angular.

sudo ng new angular-app

And this is what happened

As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release,
which will only support Node 6.9 and greater. This package will be officially deprecated
shortly after.

To disable this warning use “ng set –global warnings.packageDeprecation=false”.

installing ng2
create .editorconfig
create src/app/app.component.css
create src/app/app.component.html
create karma.conf.js
create package.json
create protractor.conf.js
create tslint.json
Directory is already under version control. Skipping initialization of git.
Installing packages for tooling via npm.

It was stuck at the

Installing packages for tooling via npm

for ages and since I didn’t want to give up using the CLI, here is how I solved it.

$ ng new angular-app --skip-npm

As it was stuck on npm packages install process and using –verbose with the command didn’t help, I used above command to skip installing npm packages and did it manually.

So after above, I used

$ cd angular-app

to get into the directory and then installed npm via

$ npm install

that install script takes care if everything else that CLI does if it all works normally.

Now, since we are using the CLI, here is how to compile and run it

$ ng serve

and it should show something like following when it all works nicely.

** NG Live Development Server is running on http://localhost:4200. **
Hash: a1114768f326f4da3abe
Time: 9472ms
chunk {0} polyfills.bundle.js, (polyfills) 147 kB {4} [initial] [rendered]
chunk {1} main.bundle.js, (main) 3.98 kB {3} [initial] [rendered]
chunk {2} styles.bundle.js, (styles) 10 kB {4} [initial] [rendered]
chunk {3} vendor.bundle.js, (vendor) 2.62 MB [initial] [rendered]
chunk {4} inline.bundle.js, (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.

Heading into the browser, it looked like this

Problem solved!

Leave a Reply

Your email address will not be published. Required fields are marked *