developer747
developer747

Reputation: 15928

Angular2 cli hangs while creating a new app

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?

Upvotes: 18

Views: 15062

Answers (13)

Gopal Bairwa
Gopal Bairwa

Reputation: 139

I was having similar issue while setting up Angular on windows 10. It was getting stuck while installing dependencies after all the CREATE's were done for the first application. For me this was happening because I was running the command from my laptop sitting at home and was connected to company VPN. When I disconnected from VPN and commented out the proxy settings in .npmrc ( it was needed for npm to work via corporate network ) the issue got resolved.

Upvotes: 0

adesh
adesh

Reputation: 11

The main reason for this is because the npm tries to install the dependencies.

You can skip to install the dependencies right now. And then install them later by using following command :

ng new myAppName --skip--install

and then go to myAppName and run npm install

cd myAppName
npm install

After all the dependencies are installed. Now you can start you application using :

npm start

For more info please read the following thread : https://github.com/angular/angular-cli/issues/3032

Upvotes: 0

Enayat
Enayat

Reputation: 4042

I had the same problem. Just waited a bit longer and finally it create the project. So, be patient!

Upvotes: 1

Ghasem
Ghasem

Reputation: 15573

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

Upvotes: 1

rudrasiva86
rudrasiva86

Reputation: 583

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

Upvotes: 21

Vivek Nag
Vivek Nag

Reputation: 1

I had the same problem. I waited a little longer and it said Installed packages for tooling via npm.

Checkout this issue on github for the same:
https://github.com/angular/angular-cli/issues/3032

Running it with --skip-install or --skip-npm worked for some.

ng new myAppName --skip-install

Upvotes: 0

Shashank
Shashank

Reputation: 407

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

Upvotes: 4

Mike Rodov
Mike Rodov

Reputation: 597

I actually had the same problem, which was resulted by a VERY slow net connection

"Installing packages for tooling via npm." downloads and installs the tool so it migth take few minutes

  1. If you are installing on Linux you need to install angular-cli without root permissions https://docs.npmjs.com/getting-started/fixing-npm-permissions

  2. You probably need to delete the new project directory created, on linux run "rm -rf myprojectname" where myprojectname stands for the name of your project

Upvotes: 0

phil294
phil294

Reputation: 10832

If you're not getting an error, delete the node_modules and require then anew by npm install. In my case, after that I saw an actual error message which was:

Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 39:16 in the original .ts file), resolving symbol AppModule in /..../app/app.module.ts, after defining a factory for a provider in my module.

Maybe this will help someone.

Upvotes: 0

Murali
Murali

Reputation: 63

1) Uninstall the angular-cli

sudo npm uninstall -g angular-cli

2) Try cache clean

npm cache clean

3) Install angular-cli

sudo npm install -g angular-cli

Upvotes: 0

mapm
mapm

Reputation: 1395

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

Upvotes: 1

M Fuat
M Fuat

Reputation: 1440

Try to install the last version of node.js because according to angular 2 site :

If Node.js and npm aren't already on your machine, install them. Our examples require node v5.x.x or higher and npm 3.x.x or higher. To check which version you are using, run node -v and npm -v in a terminal window.

Angular 2

Upvotes: 0

Jasmin
Jasmin

Reputation: 36

Try npm cache clean

If angular cli already installed, run ng new command

ng new xxx

Hope this helps.

Thanks, Jasmin

Upvotes: 1

Related Questions