0

I have installed the angular/cli but ng command is not working as global

C:\Projects>ng -v 'ng' is not recognized as an internal or external command, operable program or batch file.

Mike Feltman
  • 5,160
  • 1
  • 17
  • 38
prashu
  • 25
  • 8

3 Answers3

0

In your command line tool use: npm install -g @angular/cli@latest

Make sure you have installed NodeJS first.

Bogdan Bogdanov
  • 386
  • 1
  • 9
0

Follow the below steps to start with angular CLI.

First update node version:

  1. So, first check your node version by typing command node -v.
  2. If node version is lower than 6.x.x then update it because angular CLI requires node version to be higher than 6.x.x. To update node version run the below command.

    nvm install <new version> --reinstall-packages-from=<old version>

    Ex: nvm install 7.10.0 --reinstall-packages-from=5.1.0

    Then run command: nvm use 7.10.0

  3. After this run command npm install -g @angular/cli to install Angular CLI.

  4. Then ng new my-new-project to create new project.
  5. Then cd my-new-project to go inside created project directory.
  6. And then finally ng serve to run your app.

Extra: To update your angular 2 project into angular 4 project run below command:

    * On Linux/Mac: npm install @angular/{common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-    
                     server,router,animations}@next --save server,router,animations}@next --save

     * On Windows: npm install @angular/common@next @angular/compiler@next @angular/compiler-cli@next @angular/core@next 
                   @angular/forms@next @angular/http@next @angular/platform-browser@next @angular/platform-browser-dynamic@next 
                   @angular/platform-server@next @angular/  router@next @angular/animations@next --save
Surjeet Bhadauriya
  • 6,755
  • 3
  • 34
  • 52
0

Yes, it was related to node version, i have upgraded the node version higher than 6.x.x and now it is working.

prashu
  • 25
  • 8