Angular2 cli hangs while creating a new app

14,346

Solution 1

I was having the same issue. I resolved by using yarn. Follow below steps

  1. Install yarn through npm using the below command

    npm install yarn --global

  2. Create your application using ng new but skip installing packages using the below command. You can install them manually using yarn

    ng new project-name --skip-install

  3. cd project-name

  4. yarn install This will install your dependencies super-fast

Solution 2

Try to run cmd as Administrator, it will take 4 to 5 minutes.

Solution 3

To fix this issue run

ng new myAppName --skip-install

then in command line go to the new project folder

cd myAppName

then run

npm install

This fixed the problem for me.

The second way is to just press Ctrl + C at the time it hangs on

 Installing packages for tooling via npm

and the go to the project folder and run npm install

Solution 4

Try npm cache clean

If angular cli already installed, run ng new command

ng new xxx

Hope this helps.

Thanks, Jasmin

Solution 5

Some people install angular-cli using root user (sudo) because on some systems using a regular user will cause a permission error. But his may cause further problems like the one you are facing.

To fix it:

1) Remove your global angular-cli (using sudo):

sudo npm uninstall -g angular-cli

2) Follow the instructions on page below to fix npm permissions:

https://docs.npmjs.com/getting-started/fixing-npm-permissions

3) Reinstall angular-cli, this time not using sudo:

npm install -g angular-cli
Share:
14,346

Related videos on Youtube

developer747
Author by

developer747

"Abstractions save us time working, but they don't save us time learning."-Joel Spolsky

Updated on September 14, 2022

Comments

  • developer747
    developer747 over 1 year

    I am trying to create a new Angular2 app using

    ng new myAppName
    

    This hangs on the line

    / Installing packages for tooling via npm   
    

    Its been sitting there for about an hour.

    The previous time this happend I killed the process and tried re-running

    ng new xxx
    

    That failed because angular cli had some reference to the app name somewhere and thats whay I had to choose a new app name.

    How do I get around this?

    • Kyle Vassella
      Kyle Vassella almost 7 years
      I was trying to install Angular on an external flash drive which I believe was part of my problem. Siva Sankar's method Yarn worked for me, although I also had to move my Angular app directory to my laptop's HDD.
  • user3183717
    user3183717 about 7 years
    I was having the exact same problem and this fixed my issue.
  • Santhucool
    Santhucool almost 7 years
    @Siva Sankar Rajendran I am getting error when I give yarn install as follows error An unexpected error occurred: "registry.yarnpkg.com/@angular%2fplatform-browser: unable to get local issuer certificate". info If you think this is a bug, please open a bug report with the information provided in "D:\\learn\\my-cli-app\\yarn-error.log". info Visit yarnpkg.com/en/docs/cli/install for documentation about this command.
  • chribonn
    chribonn over 6 years
    Worked for me. It literally took minutes.
  • Raymond Dumalaog
    Raymond Dumalaog over 6 years
    How long did yours install?
  • Enayat
    Enayat over 6 years
    At most 5 minutes.
  • Ben D
    Ben D about 5 years
    this worked for myself after many hours fighting with npm. Note - I did have to run the following to gert around the certificate issue mentioned above: yarn config set "strict-ssl" false -g